/*
 * Class ActionButtons
 *
 * Version 1.0
 *
 * Monday, August 18, 2008
 *
 * Created by Palidino76
 */
 
 /*
 		if (p.firstLog < 1) {
			p.frames.showInterface(p, 771);
			p.frames.setWindowPane(p, 549);
			p.frames.setInterface(p, 1, 549, 2, 771);

*/
package palidino76.rs2.io.packets;

import palidino76.rs2.*;
import palidino76.rs2.player.quest.*;
import palidino76.rs2.player.games.*;
import palidino76.rs2.player.Player;
import palidino76.rs2.player.Magic;
import palidino76.rs2.util.Misc;

public class ActionButtons implements Packet {
    /**
     * Handles buttons on interfaces.
     * @param p The Player which the frame should be handled for.
     * @param packetId The packet id this belongs to.
     * @param packetSize The amount of bytes being recieved for this packet.
     */
    public void handlePacket(Player p, int packetId, int packetSize) {
        if (p == null || p.stream == null) {
            return;
        }
        int interfaceId = p.stream.readUnsignedWord();
        int buttonId = p.stream.readUnsignedWord();
        int buttonId2 = 0;
		if (packetId == 233 || packetId == 21 || packetId == 169 || packetId == 232 || packetId == 214 || packetId == 90 || packetId == 173 || packetId == 133 || packetId == 226 || packetId == 102) {
			buttonId2 = p.stream.readUnsignedWord();
		}
        if (buttonId2 == 65535) {
            buttonId2 = 0;
        }
	int warriorLevel = p.getLevelForXP(0) + p.getLevelForXP(2);
	QuestDevelopment quest = new QuestDevelopment(p);
	FightCave fCave = new FightCave(p);
	DuelArena duelArena = new DuelArena(p);
	Misc.println("Interface Id: "+interfaceId+" Button Id: "+buttonId+".");
        switch (interfaceId) {
				case 740:
					if (buttonId == 4) {
						p.frames.setConfig(p, 1179, 0);
						p.frames.removeShownInterface(p);
					}
				break;
				case 320: // Skills Tab.
				boolean lvlup = false;
				switch(buttonId) {
					case 125: //Attack
						if(!p.leveledUp[0]){
							p.skillMenu = 1;
							lvlup = false;
							p.frames.setConfig(p, 965, 1);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 10);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 126: //Strength
						if(!p.leveledUp[2]){
							p.skillMenu = 2;
							lvlup = false;
							p.frames.setConfig(p, 965, 2);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 20);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 127: //Defence
						if(!p.leveledUp[1]){
							p.skillMenu = 5;
							lvlup = false;
							p.frames.setConfig(p, 965, 5);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 40);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 128: //Ranged
						if(!p.leveledUp[4]){
							p.skillMenu = 3;
							lvlup = false;
							p.frames.setConfig(p, 965, 3);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 30);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 129: //Prayer
						if(!p.leveledUp[5]){
							p.skillMenu = 7;
							lvlup = false;
							p.frames.setConfig(p, 965, 7);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 60);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 130: //Magic
						if(!p.leveledUp[6]){
							p.skillMenu = 4;
							lvlup = false;
							p.frames.setConfig(p, 965, 4);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 33);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 131: //Runecrafting
						if(!p.leveledUp[20]){
							p.skillMenu = 12;
							lvlup = false;
							p.frames.setConfig(p, 965, 12);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 100);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 132: //Construction
						if(!p.leveledUp[21]){
							p.skillMenu = 22;
							lvlup = false;
							p.frames.setConfig(p, 965, 22);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 698);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 133: //Hitpoints
						if(!p.leveledUp[3]){
							p.skillMenu = 6;
							lvlup = false;
							p.frames.setConfig(p, 965, 6);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 50);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 134: //Agility
						if(!p.leveledUp[16]){
							p.skillMenu = 8;
							lvlup = false;
							p.frames.setConfig(p, 965, 8);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 65);
							p.frames.setConfig(p, 1179, 128);
						}
				        break;
				    case 135: //Herblore
						if(!p.leveledUp[15]){
							p.skillMenu = 9;
							lvlup = false;
							p.frames.setConfig(p, 965, 9);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 75);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 136: //Thieving
						if(!p.leveledUp[17]){
							p.skillMenu = 10;
							lvlup = false;
							p.frames.setConfig(p, 965, 10);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 80);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 137: //Crafting
						if(!p.leveledUp[12]){
							p.skillMenu = 11;
							lvlup = false;
							p.frames.setConfig(p, 965, 11);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 90);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 138: //Fletching
						if(!p.leveledUp[9]){
							p.skillMenu = 19;
							lvlup = false;
							p.frames.setConfig(p, 965, 19);

						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 665);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 139: //Slayer
						if(!p.leveledUp[18]){
							p.skillMenu = 20;
							lvlup = false;
							p.frames.setConfig(p, 965, 20);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 673);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 140: //Hunter
						if(!p.leveledUp[22]){
							p.skillMenu = 23;
							lvlup = false;
							p.frames.setConfig(p, 965, 23);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 689);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 141: //Mining
						if(!p.leveledUp[14]){
							p.skillMenu = 13;
							lvlup = false;
							p.frames.setConfig(p, 965, 13);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 110);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 142: //Smithing
						if(!p.leveledUp[13]){
							p.skillMenu = 14;
							lvlup = false;
							p.frames.setConfig(p, 965, 14);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 115);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 143: //Fishing
						if(!p.leveledUp[10]){
							p.skillMenu = 15;
							lvlup = false;
							p.frames.setConfig(p, 965, 15);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 120);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 144: //Cooking
						if(!p.leveledUp[7]){
							p.skillMenu = 16;
							lvlup = false;
							p.frames.setConfig(p, 965, 16);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 641);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 145: //Firemaking
						if(!p.leveledUp[11]){
							p.skillMenu = 17;
							lvlup = false;
							p.frames.setConfig(p, 965, 17);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 649);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 146: //Woodcutting
						if(!p.leveledUp[8]){
							p.skillMenu = 18;
							lvlup = false;
							p.frames.setConfig(p, 965, 18);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 660);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 147: //Farming
						if(!p.leveledUp[19]){
							p.skillMenu = 21;
							lvlup = false;
							p.frames.setConfig(p, 965, 21);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 681);
							p.frames.setConfig(p, 1179, 0);
						}
				        break;
				    case 148: //Summoning
						if(!p.leveledUp[23]){
							p.skillMenu = 24;
							lvlup = false;
							p.frames.setConfig(p, 965, 24);
						} else {
							lvlup = true;
							p.frames.setConfig(p, 1230, 705);
							p.frames.setConfig(p, 1179, 0);
						}
						p.frames.showInterface(p, 499);
				        break;
				}
				if(!lvlup){
					p.frames.showInterface(p, 499);
				} else {
					p.frames.showInterface(p, 741);
				}
				lvlup = false;
				for(int i = 0; i < 24; i++)
					p.leveledUp[i] = false;
				break;


			case 499: // Skill Information.
				switch(buttonId) {
					case 10:
		                p.frames.setConfig(p, 965, p.skillMenu);
						break;
		            case 11:
		                p.frames.setConfig(p, 965, 1024 + p.skillMenu);
			            break;
		            case 12:
		                p.frames.setConfig(p, 965, 2048 + p.skillMenu);
						break;
		            case 13:
		                p.frames.setConfig(p, 965, 3072 + p.skillMenu);
						break;
		            case 14:
		                p.frames.setConfig(p, 965, 4096 + p.skillMenu);
						break;
		            case 15:
		                p.frames.setConfig(p, 965, 5120 + p.skillMenu);
						break;
		            case 16:
		                p.frames.setConfig(p, 965, 6144 + p.skillMenu);
						break;
		            case 17:
		                p.frames.setConfig(p, 965, 7168 + p.skillMenu);
						break;
		            case 18:
		                p.frames.setConfig(p, 965, 8192 + p.skillMenu);
						break;
		            case 19:
		                p.frames.setConfig(p, 965, 9216 + p.skillMenu);
						break;
		            case 20:
		                p.frames.setConfig(p, 965, 10240 + p.skillMenu);
						break;
		            case 21:
		                p.frames.setConfig(p, 965, 11264 + p.skillMenu);
						break;
		            case 22:
		                p.frames.setConfig(p, 965, 12288 + p.skillMenu);
						break;
		            case 23:
		                p.frames.setConfig(p, 965, 13312 + p.skillMenu);
						break;
					default:
			            break;
				}
				break;

		case 274:
if (p.StraightChamp == 0 && p.skillLvl[5] < 43 && p.skillLvl[18] < 35 && p.skillLvl[17] < 50) {
			if (buttonId == 131) { //Straight Champions Quest
				p.frames.showInterface(p, 275);
				p.frames.setString(p, "Straight Champion", 275, 2);
				p.frames.setString(p, "", 275, 10);
				p.frames.setString(p, "To start this quest speak to the Grumpy Old-Man in Edgeville.", 275, 11);
				p.frames.setString(p, "To start this quest you need the following requirements:", 275, 12);
				p.frames.setString(p, "          <col=0000FF>35 Slayer", 275, 13);
				p.frames.setString(p, "          <col=0000FF>50 Thieving", 275, 14);
				p.frames.setString(p, "          <col=0000FF>43 Prayer", 275, 15);
				p.frames.setString(p, "", 275, 16);
				p.frames.setString(p, "", 275, 17);
				p.frames.setString(p, "", 275, 18);
				p.frames.setString(p, "", 275, 19);
				p.frames.setString(p, "", 275, 20);
				p.frames.setString(p, "", 275, 21);
				p.frames.setString(p, "", 275, 22);
				p.frames.setString(p, "", 275, 23);
				p.frames.setString(p, "", 275, 24);
				p.frames.setString(p, "", 275, 25);
				p.frames.setString(p, "", 275, 26);
				p.frames.setString(p, "", 275, 27);
				p.frames.setString(p, "", 275, 28);
				p.frames.setString(p, "", 275, 29);
				p.frames.setString(p, "", 275, 30);
				p.frames.setString(p, "", 275, 31);
				p.frames.setString(p, "", 275, 32);
				p.frames.setString(p, "", 275, 33);
				p.frames.setString(p, "", 275, 34);
				p.frames.setString(p, "", 275, 35);
				p.frames.setString(p, "", 275, 36);
				p.frames.setString(p, "", 275, 37);
				p.frames.setString(p, "", 275, 38);
				p.frames.setString(p, "", 275, 39);
				p.frames.setString(p, "", 275, 40);
				p.frames.setString(p, "", 275, 41);
				p.frames.setString(p, "", 275, 42);
				p.frames.setString(p, "", 275, 43);
				p.frames.setString(p, "", 275, 44);
				p.frames.setString(p, "", 275, 45);
				p.frames.setString(p, "", 275, 46);
				p.frames.setString(p, "", 275, 47);
				p.frames.setString(p, "", 275, 48);
				p.frames.setString(p, "", 275, 49);
				p.frames.setString(p, "", 275, 50);
				p.frames.setString(p, "", 275, 51);
				p.frames.setString(p, "", 275, 52);
				p.frames.setString(p, "", 275, 53);
				p.frames.setString(p, "", 275, 54);
				p.frames.setString(p, "", 275, 55);
				p.frames.setString(p, "", 275, 56);
				p.frames.setString(p, "", 275, 57);
				p.frames.setString(p, "", 275, 58);
				p.frames.setString(p, "", 275, 59);
				p.frames.setString(p, "", 275, 60);
			}
		}
		if (p.StraightChamp == 0 && p.skillLvl[5] < 43 && p.skillLvl[18] < 35 && p.skillLvl[17] > 49) {
			if (buttonId == 131) { //Straight Champions Quest
				p.frames.showInterface(p, 275);
				p.frames.setString(p, "Straight Champion", 275, 2);
				p.frames.setString(p, "", 275, 10);
				p.frames.setString(p, "To start this quest speak to the Grumpy Old-Man in Edgeville.", 275, 11);
				p.frames.setString(p, "To start this quest you need the following requirements:", 275, 12);
				p.frames.setString(p, "          <col=0000FF>35 Slayer", 275, 13);
				p.frames.setString(p, "          <str><col=0000FF>50 Thieving", 275, 14);
				p.frames.setString(p, "          <col=0000FF>43 Prayer", 275, 15);
				p.frames.setString(p, "", 275, 16);
				p.frames.setString(p, "", 275, 17);
				p.frames.setString(p, "", 275, 18);
				p.frames.setString(p, "", 275, 19);
				p.frames.setString(p, "", 275, 20);
				p.frames.setString(p, "", 275, 21);
				p.frames.setString(p, "", 275, 22);
				p.frames.setString(p, "", 275, 23);
				p.frames.setString(p, "", 275, 24);
				p.frames.setString(p, "", 275, 25);
				p.frames.setString(p, "", 275, 26);
				p.frames.setString(p, "", 275, 27);
				p.frames.setString(p, "", 275, 28);
				p.frames.setString(p, "", 275, 29);
				p.frames.setString(p, "", 275, 30);
				p.frames.setString(p, "", 275, 31);
				p.frames.setString(p, "", 275, 32);
				p.frames.setString(p, "", 275, 33);
				p.frames.setString(p, "", 275, 34);
				p.frames.setString(p, "", 275, 35);
				p.frames.setString(p, "", 275, 36);
				p.frames.setString(p, "", 275, 37);
				p.frames.setString(p, "", 275, 38);
				p.frames.setString(p, "", 275, 39);
				p.frames.setString(p, "", 275, 40);
				p.frames.setString(p, "", 275, 41);
				p.frames.setString(p, "", 275, 42);
				p.frames.setString(p, "", 275, 43);
				p.frames.setString(p, "", 275, 44);
				p.frames.setString(p, "", 275, 45);
				p.frames.setString(p, "", 275, 46);
				p.frames.setString(p, "", 275, 47);
				p.frames.setString(p, "", 275, 48);
				p.frames.setString(p, "", 275, 49);
				p.frames.setString(p, "", 275, 50);
				p.frames.setString(p, "", 275, 51);
				p.frames.setString(p, "", 275, 52);
				p.frames.setString(p, "", 275, 53);
				p.frames.setString(p, "", 275, 54);
				p.frames.setString(p, "", 275, 55);
				p.frames.setString(p, "", 275, 56);
				p.frames.setString(p, "", 275, 57);
				p.frames.setString(p, "", 275, 58);
				p.frames.setString(p, "", 275, 59);
				p.frames.setString(p, "", 275, 60);
			}
		}
		if (p.StraightChamp == 0 && p.skillLvl[5] < 43 && p.skillLvl[18] > 34 && p.skillLvl[17] < 50) {
			if (buttonId == 131) { //Straight Champions Quest
				p.frames.showInterface(p, 275);
				p.frames.setString(p, "Straight Champion", 275, 2);
				p.frames.setString(p, "", 275, 10);
				p.frames.setString(p, "To start this quest speak to the Grumpy Old-Man in Edgeville.", 275, 11);
				p.frames.setString(p, "To start this quest you need the following requirements:", 275, 12);
				p.frames.setString(p, "          <str><col=0000FF>35 Slayer", 275, 13);
				p.frames.setString(p, "          <col=0000FF>50 Thieving", 275, 14);
				p.frames.setString(p, "          <col=0000FF>43 Prayer", 275, 15);
				p.frames.setString(p, "", 275, 16);
				p.frames.setString(p, "", 275, 17);
				p.frames.setString(p, "", 275, 18);
				p.frames.setString(p, "", 275, 19);
				p.frames.setString(p, "", 275, 20);
				p.frames.setString(p, "", 275, 21);
				p.frames.setString(p, "", 275, 22);
				p.frames.setString(p, "", 275, 23);
				p.frames.setString(p, "", 275, 24);
				p.frames.setString(p, "", 275, 25);
				p.frames.setString(p, "", 275, 26);
				p.frames.setString(p, "", 275, 27);
				p.frames.setString(p, "", 275, 28);
				p.frames.setString(p, "", 275, 29);
				p.frames.setString(p, "", 275, 30);
				p.frames.setString(p, "", 275, 31);
				p.frames.setString(p, "", 275, 32);
				p.frames.setString(p, "", 275, 33);
				p.frames.setString(p, "", 275, 34);
				p.frames.setString(p, "", 275, 35);
				p.frames.setString(p, "", 275, 36);
				p.frames.setString(p, "", 275, 37);
				p.frames.setString(p, "", 275, 38);
				p.frames.setString(p, "", 275, 39);
				p.frames.setString(p, "", 275, 40);
				p.frames.setString(p, "", 275, 41);
				p.frames.setString(p, "", 275, 42);
				p.frames.setString(p, "", 275, 43);
				p.frames.setString(p, "", 275, 44);
				p.frames.setString(p, "", 275, 45);
				p.frames.setString(p, "", 275, 46);
				p.frames.setString(p, "", 275, 47);
				p.frames.setString(p, "", 275, 48);
				p.frames.setString(p, "", 275, 49);
				p.frames.setString(p, "", 275, 50);
				p.frames.setString(p, "", 275, 51);
				p.frames.setString(p, "", 275, 52);
				p.frames.setString(p, "", 275, 53);
				p.frames.setString(p, "", 275, 54);
				p.frames.setString(p, "", 275, 55);
				p.frames.setString(p, "", 275, 56);
				p.frames.setString(p, "", 275, 57);
				p.frames.setString(p, "", 275, 58);
				p.frames.setString(p, "", 275, 59);
				p.frames.setString(p, "", 275, 60);
			}
		}
		if (p.StraightChamp == 0 && p.skillLvl[5] > 42 && p.skillLvl[18] < 35 && p.skillLvl[17] < 50) {
			if (buttonId == 131) { //Straight Champions Quest
				p.frames.showInterface(p, 275);
				p.frames.setString(p, "Straight Champion", 275, 2);
				p.frames.setString(p, "", 275, 10);
				p.frames.setString(p, "To start this quest speak to the Grumpy Old-Man in Edgeville.", 275, 11);
				p.frames.setString(p, "To start this quest you need the following requirements:", 275, 12);
				p.frames.setString(p, "          <col=0000FF>35 Slayer", 275, 13);
				p.frames.setString(p, "          <col=0000FF>50 Thieving", 275, 14);
				p.frames.setString(p, "          <str><col=0000FF>43 Prayer", 275, 15);
				p.frames.setString(p, "", 275, 16);
				p.frames.setString(p, "", 275, 17);
				p.frames.setString(p, "", 275, 18);
				p.frames.setString(p, "", 275, 19);
				p.frames.setString(p, "", 275, 20);
				p.frames.setString(p, "", 275, 21);
				p.frames.setString(p, "", 275, 22);
				p.frames.setString(p, "", 275, 23);
				p.frames.setString(p, "", 275, 24);
				p.frames.setString(p, "", 275, 25);
				p.frames.setString(p, "", 275, 26);
				p.frames.setString(p, "", 275, 27);
				p.frames.setString(p, "", 275, 28);
				p.frames.setString(p, "", 275, 29);
				p.frames.setString(p, "", 275, 30);
				p.frames.setString(p, "", 275, 31);
				p.frames.setString(p, "", 275, 32);
				p.frames.setString(p, "", 275, 33);
				p.frames.setString(p, "", 275, 34);
				p.frames.setString(p, "", 275, 35);
				p.frames.setString(p, "", 275, 36);
				p.frames.setString(p, "", 275, 37);
				p.frames.setString(p, "", 275, 38);
				p.frames.setString(p, "", 275, 39);
				p.frames.setString(p, "", 275, 40);
				p.frames.setString(p, "", 275, 41);
				p.frames.setString(p, "", 275, 42);
				p.frames.setString(p, "", 275, 43);
				p.frames.setString(p, "", 275, 44);
				p.frames.setString(p, "", 275, 45);
				p.frames.setString(p, "", 275, 46);
				p.frames.setString(p, "", 275, 47);
				p.frames.setString(p, "", 275, 48);
				p.frames.setString(p, "", 275, 49);
				p.frames.setString(p, "", 275, 50);
				p.frames.setString(p, "", 275, 51);
				p.frames.setString(p, "", 275, 52);
				p.frames.setString(p, "", 275, 53);
				p.frames.setString(p, "", 275, 54);
				p.frames.setString(p, "", 275, 55);
				p.frames.setString(p, "", 275, 56);
				p.frames.setString(p, "", 275, 57);
				p.frames.setString(p, "", 275, 58);
				p.frames.setString(p, "", 275, 59);
				p.frames.setString(p, "", 275, 60);
			}
		}
		if (p.StraightChamp == 0 && p.skillLvl[5] > 42 && p.skillLvl[18] > 34 && p.skillLvl[17] < 50) {
			if (buttonId == 131) { //Straight Champions Quest
				p.frames.showInterface(p, 275);
				p.frames.setString(p, "Straight Champion", 275, 2);
				p.frames.setString(p, "", 275, 10);
				p.frames.setString(p, "To start this quest speak to the Grumpy Old-Man in Edgeville.", 275, 11);
				p.frames.setString(p, "To start this quest you need the following requirements:", 275, 12);
				p.frames.setString(p, "          <str><col=0000FF>35 Slayer", 275, 13);
				p.frames.setString(p, "          <col=0000FF>50 Thieving", 275, 14);
				p.frames.setString(p, "          <str><col=0000FF>43 Prayer", 275, 15);
				p.frames.setString(p, "", 275, 16);
				p.frames.setString(p, "", 275, 17);
				p.frames.setString(p, "", 275, 18);
				p.frames.setString(p, "", 275, 19);
				p.frames.setString(p, "", 275, 20);
				p.frames.setString(p, "", 275, 21);
				p.frames.setString(p, "", 275, 22);
				p.frames.setString(p, "", 275, 23);
				p.frames.setString(p, "", 275, 24);
				p.frames.setString(p, "", 275, 25);
				p.frames.setString(p, "", 275, 26);
				p.frames.setString(p, "", 275, 27);
				p.frames.setString(p, "", 275, 28);
				p.frames.setString(p, "", 275, 29);
				p.frames.setString(p, "", 275, 30);
				p.frames.setString(p, "", 275, 31);
				p.frames.setString(p, "", 275, 32);
				p.frames.setString(p, "", 275, 33);
				p.frames.setString(p, "", 275, 34);
				p.frames.setString(p, "", 275, 35);
				p.frames.setString(p, "", 275, 36);
				p.frames.setString(p, "", 275, 37);
				p.frames.setString(p, "", 275, 38);
				p.frames.setString(p, "", 275, 39);
				p.frames.setString(p, "", 275, 40);
				p.frames.setString(p, "", 275, 41);
				p.frames.setString(p, "", 275, 42);
				p.frames.setString(p, "", 275, 43);
				p.frames.setString(p, "", 275, 44);
				p.frames.setString(p, "", 275, 45);
				p.frames.setString(p, "", 275, 46);
				p.frames.setString(p, "", 275, 47);
				p.frames.setString(p, "", 275, 48);
				p.frames.setString(p, "", 275, 49);
				p.frames.setString(p, "", 275, 50);
				p.frames.setString(p, "", 275, 51);
				p.frames.setString(p, "", 275, 52);
				p.frames.setString(p, "", 275, 53);
				p.frames.setString(p, "", 275, 54);
				p.frames.setString(p, "", 275, 55);
				p.frames.setString(p, "", 275, 56);
				p.frames.setString(p, "", 275, 57);
				p.frames.setString(p, "", 275, 58);
				p.frames.setString(p, "", 275, 59);
				p.frames.setString(p, "", 275, 60);
			}
		}
		if (p.StraightChamp == 0 && p.skillLvl[5] > 42 && p.skillLvl[18] < 35 && p.skillLvl[17] > 49) {
			if (buttonId == 131) { //Straight Champions Quest
				p.frames.showInterface(p, 275);
				p.frames.setString(p, "Straight Champion", 275, 2);
				p.frames.setString(p, "", 275, 10);
				p.frames.setString(p, "To start this quest speak to the Grumpy Old-Man in Edgeville.", 275, 11);
				p.frames.setString(p, "To start this quest you need the following requirements:", 275, 12);
				p.frames.setString(p, "          <col=0000FF>35 Slayer", 275, 13);
				p.frames.setString(p, "          <str><col=0000FF>50 Thieving", 275, 14);
				p.frames.setString(p, "          <str><col=0000FF>43 Prayer", 275, 15);
				p.frames.setString(p, "", 275, 16);
				p.frames.setString(p, "", 275, 17);
				p.frames.setString(p, "", 275, 18);
				p.frames.setString(p, "", 275, 19);
				p.frames.setString(p, "", 275, 20);
				p.frames.setString(p, "", 275, 21);
				p.frames.setString(p, "", 275, 22);
				p.frames.setString(p, "", 275, 23);
				p.frames.setString(p, "", 275, 24);
				p.frames.setString(p, "", 275, 25);
				p.frames.setString(p, "", 275, 26);
				p.frames.setString(p, "", 275, 27);
				p.frames.setString(p, "", 275, 28);
				p.frames.setString(p, "", 275, 29);
				p.frames.setString(p, "", 275, 30);
				p.frames.setString(p, "", 275, 31);
				p.frames.setString(p, "", 275, 32);
				p.frames.setString(p, "", 275, 33);
				p.frames.setString(p, "", 275, 34);
				p.frames.setString(p, "", 275, 35);
				p.frames.setString(p, "", 275, 36);
				p.frames.setString(p, "", 275, 37);
				p.frames.setString(p, "", 275, 38);
				p.frames.setString(p, "", 275, 39);
				p.frames.setString(p, "", 275, 40);
				p.frames.setString(p, "", 275, 41);
				p.frames.setString(p, "", 275, 42);
				p.frames.setString(p, "", 275, 43);
				p.frames.setString(p, "", 275, 44);
				p.frames.setString(p, "", 275, 45);
				p.frames.setString(p, "", 275, 46);
				p.frames.setString(p, "", 275, 47);
				p.frames.setString(p, "", 275, 48);
				p.frames.setString(p, "", 275, 49);
				p.frames.setString(p, "", 275, 50);
				p.frames.setString(p, "", 275, 51);
				p.frames.setString(p, "", 275, 52);
				p.frames.setString(p, "", 275, 53);
				p.frames.setString(p, "", 275, 54);
				p.frames.setString(p, "", 275, 55);
				p.frames.setString(p, "", 275, 56);
				p.frames.setString(p, "", 275, 57);
				p.frames.setString(p, "", 275, 58);
				p.frames.setString(p, "", 275, 59);
				p.frames.setString(p, "", 275, 60);
			}
		}
		if (p.StraightChamp == 0 && p.skillLvl[5] < 43 && p.skillLvl[18] > 34 && p.skillLvl[17] > 49) {
			if (buttonId == 131) { //Straight Champions Quest
				p.frames.showInterface(p, 275);
				p.frames.setString(p, "Straight Champion", 275, 2);
				p.frames.setString(p, "", 275, 10);
				p.frames.setString(p, "To start this quest speak to the Grumpy Old-Man in Edgeville.", 275, 11);
				p.frames.setString(p, "To start this quest you need the following requirements:", 275, 12);
				p.frames.setString(p, "          <str><col=0000FF>35 Slayer", 275, 13);
				p.frames.setString(p, "          <str><col=0000FF>50 Thieving", 275, 14);
				p.frames.setString(p, "          <col=0000FF>43 Prayer", 275, 15);
				p.frames.setString(p, "", 275, 16);
				p.frames.setString(p, "", 275, 17);
				p.frames.setString(p, "", 275, 18);
				p.frames.setString(p, "", 275, 19);
				p.frames.setString(p, "", 275, 20);
				p.frames.setString(p, "", 275, 21);
				p.frames.setString(p, "", 275, 22);
				p.frames.setString(p, "", 275, 23);
				p.frames.setString(p, "", 275, 24);
				p.frames.setString(p, "", 275, 25);
				p.frames.setString(p, "", 275, 26);
				p.frames.setString(p, "", 275, 27);
				p.frames.setString(p, "", 275, 28);
				p.frames.setString(p, "", 275, 29);
				p.frames.setString(p, "", 275, 30);
				p.frames.setString(p, "", 275, 31);
				p.frames.setString(p, "", 275, 32);
				p.frames.setString(p, "", 275, 33);
				p.frames.setString(p, "", 275, 34);
				p.frames.setString(p, "", 275, 35);
				p.frames.setString(p, "", 275, 36);
				p.frames.setString(p, "", 275, 37);
				p.frames.setString(p, "", 275, 38);
				p.frames.setString(p, "", 275, 39);
				p.frames.setString(p, "", 275, 40);
				p.frames.setString(p, "", 275, 41);
				p.frames.setString(p, "", 275, 42);
				p.frames.setString(p, "", 275, 43);
				p.frames.setString(p, "", 275, 44);
				p.frames.setString(p, "", 275, 45);
				p.frames.setString(p, "", 275, 46);
				p.frames.setString(p, "", 275, 47);
				p.frames.setString(p, "", 275, 48);
				p.frames.setString(p, "", 275, 49);
				p.frames.setString(p, "", 275, 50);
				p.frames.setString(p, "", 275, 51);
				p.frames.setString(p, "", 275, 52);
				p.frames.setString(p, "", 275, 53);
				p.frames.setString(p, "", 275, 54);
				p.frames.setString(p, "", 275, 55);
				p.frames.setString(p, "", 275, 56);
				p.frames.setString(p, "", 275, 57);
				p.frames.setString(p, "", 275, 58);
				p.frames.setString(p, "", 275, 59);
				p.frames.setString(p, "", 275, 60);
			}
		}
		if (p.StraightChamp == 0 && p.skillLvl[5] > 42 && p.skillLvl[18] > 34 && p.skillLvl[17] > 49) {
			if (buttonId == 131) { //Straight Champions Quest
				p.frames.showInterface(p, 275);
				p.frames.setString(p, "Straight Champion", 275, 2);
				p.frames.setString(p, "", 275, 10);
				p.frames.setString(p, "To start this quest speak to the Grumpy Old-Man in Edgeville.", 275, 11);
				p.frames.setString(p, "To start this quest you need the following requirements:", 275, 12);
				p.frames.setString(p, "          <str><col=0000FF>35 Slayer", 275, 13);
				p.frames.setString(p, "          <str><col=0000FF>50 Thieving", 275, 14);
				p.frames.setString(p, "          <str><col=0000FF>43 Prayer", 275, 15);
				p.frames.setString(p, "", 275, 16);
				p.frames.setString(p, "", 275, 17);
				p.frames.setString(p, "", 275, 18);
				p.frames.setString(p, "", 275, 19);
				p.frames.setString(p, "", 275, 20);
				p.frames.setString(p, "", 275, 21);
				p.frames.setString(p, "", 275, 22);
				p.frames.setString(p, "", 275, 23);
				p.frames.setString(p, "", 275, 24);
				p.frames.setString(p, "", 275, 25);
				p.frames.setString(p, "", 275, 26);
				p.frames.setString(p, "", 275, 27);
				p.frames.setString(p, "", 275, 28);
				p.frames.setString(p, "", 275, 29);
				p.frames.setString(p, "", 275, 30);
				p.frames.setString(p, "", 275, 31);
				p.frames.setString(p, "", 275, 32);
				p.frames.setString(p, "", 275, 33);
				p.frames.setString(p, "", 275, 34);
				p.frames.setString(p, "", 275, 35);
				p.frames.setString(p, "", 275, 36);
				p.frames.setString(p, "", 275, 37);
				p.frames.setString(p, "", 275, 38);
				p.frames.setString(p, "", 275, 39);
				p.frames.setString(p, "", 275, 40);
				p.frames.setString(p, "", 275, 41);
				p.frames.setString(p, "", 275, 42);
				p.frames.setString(p, "", 275, 43);
				p.frames.setString(p, "", 275, 44);
				p.frames.setString(p, "", 275, 45);
				p.frames.setString(p, "", 275, 46);
				p.frames.setString(p, "", 275, 47);
				p.frames.setString(p, "", 275, 48);
				p.frames.setString(p, "", 275, 49);
				p.frames.setString(p, "", 275, 50);
				p.frames.setString(p, "", 275, 51);
				p.frames.setString(p, "", 275, 52);
				p.frames.setString(p, "", 275, 53);
				p.frames.setString(p, "", 275, 54);
				p.frames.setString(p, "", 275, 55);
				p.frames.setString(p, "", 275, 56);
				p.frames.setString(p, "", 275, 57);
				p.frames.setString(p, "", 275, 58);
				p.frames.setString(p, "", 275, 59);
				p.frames.setString(p, "", 275, 60);
			}
		}
		if (p.StraightChamp == 50) {
			if (buttonId == 131) { //Straight Champions Quest
				p.frames.showInterface(p, 275);
				p.frames.setString(p, "Straight Champion", 275, 2);
				p.frames.setString(p, "", 275, 10);
				p.frames.setString(p, "<str>To start this quest speak to the Grumpy Old-Man in Edgeville.", 275, 11);
				p.frames.setString(p, "<str>To start this quest you need the following requirements:", 275, 12);
				p.frames.setString(p, "          <str><col=0000FF>35 Slayer", 275, 13);
				p.frames.setString(p, "          <str><col=0000FF>50 Thieving", 275, 14);
				p.frames.setString(p, "          <str><col=0000FF>43 Prayer", 275, 15);
				p.frames.setString(p, "I was told to speak to King Gjuki Sorvott IV in the Champions Guild.", 275, 16);
				p.frames.setString(p, "", 275, 17);
				p.frames.setString(p, "", 275, 18);
				p.frames.setString(p, "", 275, 19);
				p.frames.setString(p, "", 275, 20);
				p.frames.setString(p, "", 275, 21);
				p.frames.setString(p, "", 275, 22);
				p.frames.setString(p, "", 275, 23);
				p.frames.setString(p, "", 275, 24);
				p.frames.setString(p, "", 275, 25);
				p.frames.setString(p, "", 275, 26);
				p.frames.setString(p, "", 275, 27);
				p.frames.setString(p, "", 275, 28);
				p.frames.setString(p, "", 275, 29);
				p.frames.setString(p, "", 275, 30);
				p.frames.setString(p, "", 275, 31);
				p.frames.setString(p, "", 275, 32);
				p.frames.setString(p, "", 275, 33);
				p.frames.setString(p, "", 275, 34);
				p.frames.setString(p, "", 275, 35);
				p.frames.setString(p, "", 275, 36);
				p.frames.setString(p, "", 275, 37);
				p.frames.setString(p, "", 275, 38);
				p.frames.setString(p, "", 275, 39);
				p.frames.setString(p, "", 275, 40);
				p.frames.setString(p, "", 275, 41);
				p.frames.setString(p, "", 275, 42);
				p.frames.setString(p, "", 275, 43);
				p.frames.setString(p, "", 275, 44);
				p.frames.setString(p, "", 275, 45);
				p.frames.setString(p, "", 275, 46);
				p.frames.setString(p, "", 275, 47);
				p.frames.setString(p, "", 275, 48);
				p.frames.setString(p, "", 275, 49);
				p.frames.setString(p, "", 275, 50);
				p.frames.setString(p, "", 275, 51);
				p.frames.setString(p, "", 275, 52);
				p.frames.setString(p, "", 275, 53);
				p.frames.setString(p, "", 275, 54);
				p.frames.setString(p, "", 275, 55);
				p.frames.setString(p, "", 275, 56);
				p.frames.setString(p, "", 275, 57);
				p.frames.setString(p, "", 275, 58);
				p.frames.setString(p, "", 275, 59);
				p.frames.setString(p, "", 275, 60);
			}
		}
		if (p.StraightChamp == 100) {
			if (buttonId == 131) { //Straight Champions Quest
				p.frames.showInterface(p, 275);
				p.frames.setString(p, "Straight Champion", 275, 2);
				p.frames.setString(p, "", 275, 10);
				p.frames.setString(p, "<str>To start this quest speak to the Grumpy Old-Man in Edgeville.", 275, 11);
				p.frames.setString(p, "<str>To start this quest you need the following requirements:", 275, 12);
				p.frames.setString(p, "          <str><col=0000FF>35 Slayer", 275, 13);
				p.frames.setString(p, "          <str><col=0000FF>50 Thieving", 275, 14);
				p.frames.setString(p, "          <str><col=0000FF>43 Prayer", 275, 15);
				p.frames.setString(p, "<str>I was told to speak to King Gjuki Sorvott IV in the Champions Guild.", 275, 16);
				p.frames.setString(p, "To become a member of the Champions Guild I need to retrieve", 275, 17);
				p.frames.setString(p, "Zealot's key from somewhere in the abandoned town of Pollnivneach.", 275, 18);
				p.frames.setString(p, "I should be careful I was told an evil spirit guards the town and", 275, 19);
				p.frames.setString(p, "can be very powerful.", 275, 20);
				p.frames.setString(p, "", 275, 21);
				p.frames.setString(p, "", 275, 22);
				p.frames.setString(p, "", 275, 23);
				p.frames.setString(p, "", 275, 24);
				p.frames.setString(p, "", 275, 25);
				p.frames.setString(p, "", 275, 26);
				p.frames.setString(p, "", 275, 27);
				p.frames.setString(p, "", 275, 28);
				p.frames.setString(p, "", 275, 29);
				p.frames.setString(p, "", 275, 30);
				p.frames.setString(p, "", 275, 31);
				p.frames.setString(p, "", 275, 32);
				p.frames.setString(p, "", 275, 33);
				p.frames.setString(p, "", 275, 34);
				p.frames.setString(p, "", 275, 35);
				p.frames.setString(p, "", 275, 36);
				p.frames.setString(p, "", 275, 37);
				p.frames.setString(p, "", 275, 38);
				p.frames.setString(p, "", 275, 39);
				p.frames.setString(p, "", 275, 40);
				p.frames.setString(p, "", 275, 41);
				p.frames.setString(p, "", 275, 42);
				p.frames.setString(p, "", 275, 43);
				p.frames.setString(p, "", 275, 44);
				p.frames.setString(p, "", 275, 45);
				p.frames.setString(p, "", 275, 46);
				p.frames.setString(p, "", 275, 47);
				p.frames.setString(p, "", 275, 48);
				p.frames.setString(p, "", 275, 49);
				p.frames.setString(p, "", 275, 50);
				p.frames.setString(p, "", 275, 51);
				p.frames.setString(p, "", 275, 52);
				p.frames.setString(p, "", 275, 53);
				p.frames.setString(p, "", 275, 54);
				p.frames.setString(p, "", 275, 55);
				p.frames.setString(p, "", 275, 56);
				p.frames.setString(p, "", 275, 57);
				p.frames.setString(p, "", 275, 58);
				p.frames.setString(p, "", 275, 59);
				p.frames.setString(p, "", 275, 60);
			}
		}
		if (p.StraightChamp == 150) {
			if (buttonId == 131) { //Straight Champions Quest
				p.frames.showInterface(p, 275);
				p.frames.setString(p, "Straight Champion", 275, 2);
				p.frames.setString(p, "", 275, 10);
				p.frames.setString(p, "<str>To start this quest speak to the Grumpy Old-Man in Edgeville.", 275, 11);
				p.frames.setString(p, "<str>To start this quest you need the following requirements:", 275, 12);
				p.frames.setString(p, "          <str><col=0000FF>35 Slayer", 275, 13);
				p.frames.setString(p, "          <str><col=0000FF>50 Thieving", 275, 14);
				p.frames.setString(p, "          <str><col=0000FF>43 Prayer", 275, 15);
				p.frames.setString(p, "<str>I was told to speak to King Gjuki Sorvott IV in the Champions Guild.", 275, 16);
				p.frames.setString(p, "<str>To become a member of the Champions Guild I need to retrieve", 275, 17);
				p.frames.setString(p, "<str>Zealot's key from somewhere in the abandoned town of Pollnivneach.", 275, 18);
				p.frames.setString(p, "<str>I should be careful I was told an evil spirit guards the town and", 275, 19);
				p.frames.setString(p, "<str>can be very powerful.", 275, 20);
				p.frames.setString(p, "I have the key now I should go back and talk to King Gjuki Sorvott IV.", 275, 21);
				p.frames.setString(p, "", 275, 22);
				p.frames.setString(p, "", 275, 23);
				p.frames.setString(p, "", 275, 24);
				p.frames.setString(p, "", 275, 25);
				p.frames.setString(p, "", 275, 26);
				p.frames.setString(p, "", 275, 27);
				p.frames.setString(p, "", 275, 28);
				p.frames.setString(p, "", 275, 29);
				p.frames.setString(p, "", 275, 30);
				p.frames.setString(p, "", 275, 31);
				p.frames.setString(p, "", 275, 32);
				p.frames.setString(p, "", 275, 33);
				p.frames.setString(p, "", 275, 34);
				p.frames.setString(p, "", 275, 35);
				p.frames.setString(p, "", 275, 36);
				p.frames.setString(p, "", 275, 37);
				p.frames.setString(p, "", 275, 38);
				p.frames.setString(p, "", 275, 39);
				p.frames.setString(p, "", 275, 40);
				p.frames.setString(p, "", 275, 41);
				p.frames.setString(p, "", 275, 42);
				p.frames.setString(p, "", 275, 43);
				p.frames.setString(p, "", 275, 44);
				p.frames.setString(p, "", 275, 45);
				p.frames.setString(p, "", 275, 46);
				p.frames.setString(p, "", 275, 47);
				p.frames.setString(p, "", 275, 48);
				p.frames.setString(p, "", 275, 49);
				p.frames.setString(p, "", 275, 50);
				p.frames.setString(p, "", 275, 51);
				p.frames.setString(p, "", 275, 52);
				p.frames.setString(p, "", 275, 53);
				p.frames.setString(p, "", 275, 54);
				p.frames.setString(p, "", 275, 55);
				p.frames.setString(p, "", 275, 56);
				p.frames.setString(p, "", 275, 57);
				p.frames.setString(p, "", 275, 58);
				p.frames.setString(p, "", 275, 59);
				p.frames.setString(p, "", 275, 60);
			}
		}
		if (p.StraightChamp == 1000) {
			if (buttonId == 131) { //Straight Champions Quest
				p.frames.showInterface(p, 275);
				p.frames.setString(p, "Straight Champion", 275, 2);
				p.frames.setString(p, "", 275, 10);
				p.frames.setString(p, "<str>To start this quest speak to the Grumpy Old-Man in Edgeville.", 275, 11);
				p.frames.setString(p, "<str>To start this quest you need the following requirements:", 275, 12);
				p.frames.setString(p, "          <str><col=0000FF>35 Slayer", 275, 13);
				p.frames.setString(p, "          <str><col=0000FF>50 Thieving", 275, 14);
				p.frames.setString(p, "          <str><col=0000FF>43 Prayer", 275, 15);
				p.frames.setString(p, "<str>I was told to speak to King Gjuki Sorvott IV in the Champions Guild.", 275, 16);
				p.frames.setString(p, "<str>To become a member of the Champions Guild I need to retrieve", 275, 17);
				p.frames.setString(p, "<str>Zealot's key from somewhere in the abandoned town of Pollnivneach.", 275, 18);
				p.frames.setString(p, "<str>I should be careful I was told an evil spirit guards the town and", 275, 19);
				p.frames.setString(p, "<str>can be very powerful.", 275, 20);
				p.frames.setString(p, "<str>I have the key now I should go back and talk to King Gjuki Sorvott IV.", 275, 21);
				p.frames.setString(p, "          <col=993300>QUEST COMPLETE!", 275, 22);
				p.frames.setString(p, "", 275, 23);
				p.frames.setString(p, "", 275, 24);
				p.frames.setString(p, "", 275, 25);
				p.frames.setString(p, "", 275, 26);
				p.frames.setString(p, "", 275, 27);
				p.frames.setString(p, "", 275, 28);
				p.frames.setString(p, "", 275, 29);
				p.frames.setString(p, "", 275, 30);
				p.frames.setString(p, "", 275, 31);
				p.frames.setString(p, "", 275, 32);
				p.frames.setString(p, "", 275, 33);
				p.frames.setString(p, "", 275, 34);
				p.frames.setString(p, "", 275, 35);
				p.frames.setString(p, "", 275, 36);
				p.frames.setString(p, "", 275, 37);
				p.frames.setString(p, "", 275, 38);
				p.frames.setString(p, "", 275, 39);
				p.frames.setString(p, "", 275, 40);
				p.frames.setString(p, "", 275, 41);
				p.frames.setString(p, "", 275, 42);
				p.frames.setString(p, "", 275, 43);
				p.frames.setString(p, "", 275, 44);
				p.frames.setString(p, "", 275, 45);
				p.frames.setString(p, "", 275, 46);
				p.frames.setString(p, "", 275, 47);
				p.frames.setString(p, "", 275, 48);
				p.frames.setString(p, "", 275, 49);
				p.frames.setString(p, "", 275, 50);
				p.frames.setString(p, "", 275, 51);
				p.frames.setString(p, "", 275, 52);
				p.frames.setString(p, "", 275, 53);
				p.frames.setString(p, "", 275, 54);
				p.frames.setString(p, "", 275, 55);
				p.frames.setString(p, "", 275, 56);
				p.frames.setString(p, "", 275, 57);
				p.frames.setString(p, "", 275, 58);
				p.frames.setString(p, "", 275, 59);
				p.frames.setString(p, "", 275, 60);
			}
}
				if (buttonId == 12) {//Varrock
				p.teleportTo(3087, 3500, 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
				p.frames.removeOverlay(p);
			} else {
				if (p.getWildernessLevel() > 20) {
				p.frames.sendMessage(p, "You are to high in the wilderness");
				return;
				}
			}
				if (buttonId == 13) {//Catherby
				p.teleportTo(2836 + Misc.random(-1 + 1), 3437 + Misc.random(-1 + 1), 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
				p.frames.removeOverlay(p);
			} else {
				if (p.getWildernessLevel() > 20) {
				p.frames.sendMessage(p, "You are to high in the wilderness");
				return;
				}
			}
				if (buttonId == 14) {//Agility Course
				p.teleportTo(2480 + Misc.random(-1 + 1), 3436 + Misc.random(-1 + 1), 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
				p.frames.removeOverlay(p);
			} else {
				if (p.getWildernessLevel() > 20) {
				p.frames.sendMessage(p, "You are to high in the wilderness");
				return;
				}
			}
				if (buttonId == 15) {//Warrior's Guild
				p.teleportTo(2873 + Misc.random(-1 + 1), 3546 + Misc.random(-1 + 1), 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
				p.frames.removeOverlay(p);
			} else {
				if (p.getWildernessLevel() > 20) {
				p.frames.sendMessage(p, "You are to high in the wilderness");
				return;
				}
			}
				if (buttonId == 16) {//Fight Pits
				p.teleportTo(2399 + Misc.random(-1 + 1), 5178 + Misc.random(-1 + 1), 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
				p.frames.removeOverlay(p);
			} else {
				if (p.getWildernessLevel() > 20) {
				p.frames.sendMessage(p, "You are to high in the wilderness");
				return;
				}
			}
				if (buttonId == 11) {//Home
				p.teleportTo(3185 + Misc.random(-1 + 1), 3442, 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
				p.frames.removeOverlay(p);
			}
				if (buttonId == 18) {//Mage Bank
				p.teleportTo(2539 + Misc.random(-2 + 4), 4716 + Misc.random(-2 + 4), 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
				p.frames.removeOverlay(p);
			} else {
				if (p.getWildernessLevel() > 20) {
				p.frames.sendMessage(p, "You are to high in the wilderness");
				return;
				}
			}
				if (buttonId == 19) {//Varrock Wildy
				p.teleportTo(3241, 3520, 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
				p.frames.removeOverlay(p);
			} else {
				if (p.getWildernessLevel() > 20) {
				p.frames.sendMessage(p, "You are to high in the wilderness");
				return;
				}
			}
				if (buttonId == 20) {//Green Dragons
				p.teleportTo(2979 + Misc.random(-2 + 4), 3511 + Misc.random(-2 + 4), 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
				p.frames.removeOverlay(p);
			} else {
				if (p.getWildernessLevel() > 20) {
				p.frames.sendMessage(p, "You are to high in the wilderness");
				return;
				}
			}
				if (buttonId == 21) {//Duel Arena
				p.frames.sendMessage(p, "Welcome to Duel Arena.");
				p.teleportTo(3375 + Misc.random(-2 + 2), 3275 + Misc.random(-2 + 2), 0, 0, 0, 8939, 8941, 1678, 0, 1679, 0);
				p.frames.showInterface(p, 627);
				p.frames.removeOverlay(p);
			} else {
				if (p.getWildernessLevel() > 20) {
				p.frames.sendMessage(p, "You are to high in the wilderness");
				return;
				}
			}
				if (buttonId == 22) {//Bounty Hunter
				p.teleportTo(3178 + Misc.random(-2 + 4), 3683 + Misc.random(-2 + 4), 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
				p.frames.removeOverlay(p);
			} else {
				if (p.getWildernessLevel() > 20) {
				p.frames.sendMessage(p, "You are to high in the wilderness");
				return;
				}
			}
				if (buttonId == 23) {//Castle Wars
				p.teleportTo(2442 + Misc.random(-2 + 1), 3090 + Misc.random(-2 + 4), 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
				p.frames.removeOverlay(p);
			} else {
				if (p.getWildernessLevel() > 20) {
				p.frames.sendMessage(p, "You are to high in the wilderness");
				return;
				}
			}
				if (buttonId == 24) {//Grand Exchange
				p.teleportTo(3165 + Misc.random(-2 + 4), 3481 + Misc.random(-2 + 4), 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
				p.frames.removeOverlay(p);
			} else {
				if (p.getWildernessLevel() > 20) {
				p.frames.sendMessage(p, "You are to high in the wilderness");
				return;
				}
			}
				if (buttonId == 17) {//GodWars
				p.frames.sendMessage(p, "You teleport to GodWars. <col=ff0000>You have been warned!");
				p.frames.showInterface(p, 327);
				p.teleportTo(2882, 5310, 2, 0, 0, 8939, 8941, 1678, 0, 1679, 0);
				p.frames.setOverlay(p, 601);
			} else {
				if (p.getWildernessLevel() > 20) {
				p.frames.sendMessage(p, "You are to high in the wilderness");
				return;
				}
			}
				if (buttonId == 3) {
				p.frames.setTab(p, 75, 259);
				}
			
		if(buttonId == 26 && p.q1 == 0) { //black knights
		p.frames.showInterface(p, 275);
        		p.frames.setString(p, "The Beginning", 275, 2);
		p.frames.setString(p, "", 275, 11);
		p.frames.setString(p, "To start this quest you need to talk to", 275, 12);
		p.frames.setString(p, "the Archaeologist located near Edgevile Bank.", 275, 13);
		p.frames.setString(p, "", 275, 14);
		p.frames.setString(p, "", 275, 15);
		p.frames.setString(p, "", 275, 16);	
		p.frames.setString(p, "", 275, 17);
		p.frames.setString(p, "", 275, 18);
		p.frames.setString(p, "", 275, 19);
		p.frames.setString(p, "", 275, 20);
		p.frames.setString(p, "", 275, 21);
		p.frames.setString(p, "", 275, 22);
		p.frames.setString(p, "", 275, 23);
		p.frames.setString(p, "", 275, 24);
		p.frames.setString(p, "", 275, 25);
		p.frames.setString(p, "", 275, 26);
		p.frames.setString(p, "", 275, 27);
		p.frames.setString(p, "", 275, 28);
		p.frames.setString(p, "", 275, 29);
		p.frames.setString(p, "", 275, 30);
		}
		if(buttonId == 26 && p.q1 == 1) {
		p.frames.showInterface(p, 275);
        		p.frames.setString(p, "The Beginning", 275, 2);
		p.frames.setString(p, "", 275, 11);
		p.frames.setString(p, "You need to bring the Archaeologist", 275, 12);
		p.frames.setString(p, "a Rune Scimitar then he will reward you!", 275, 13);
		p.frames.setString(p, "", 275, 14);
		p.frames.setString(p, "", 275, 15);
		p.frames.setString(p, "", 275, 16);	
		p.frames.setString(p, "", 275, 17);
		p.frames.setString(p, "", 275, 18);
		p.frames.setString(p, "", 275, 19);
		p.frames.setString(p, "", 275, 20);
		p.frames.setString(p, "", 275, 21);
		p.frames.setString(p, "", 275, 22);
		p.frames.setString(p, "", 275, 23);
		p.frames.setString(p, "", 275, 24);
		p.frames.setString(p, "", 275, 25);
		p.frames.setString(p, "", 275, 26);
		p.frames.setString(p, "", 275, 27);
		p.frames.setString(p, "", 275, 28);
		p.frames.setString(p, "", 275, 29);
		p.frames.setString(p, "", 275, 30);
		}
		if(buttonId == 26 && p.q1 == 15) {
		p.frames.showInterface(p, 275);
        		p.frames.setString(p, "The Beginning", 275, 2);
		p.frames.setString(p, "", 275, 11);
		p.frames.setString(p, "This quest has been completed!", 275, 12);
		p.frames.setString(p, "", 275, 13);
		p.frames.setString(p, "", 275, 14);
		p.frames.setString(p, "", 275, 15);
		p.frames.setString(p, "", 275, 16);	
		p.frames.setString(p, "", 275, 17);
		p.frames.setString(p, "", 275, 18);
		p.frames.setString(p, "", 275, 19);
		p.frames.setString(p, "", 275, 20);
		p.frames.setString(p, "", 275, 21);
		p.frames.setString(p, "", 275, 22);
		p.frames.setString(p, "", 275, 23);
		p.frames.setString(p, "", 275, 24);
		p.frames.setString(p, "", 275, 25);
		p.frames.setString(p, "", 275, 26);
		p.frames.setString(p, "", 275, 27);
		p.frames.setString(p, "", 275, 28);
		p.frames.setString(p, "", 275, 29);
		p.frames.setString(p, "", 275, 30);
		}
				if (buttonId == 136) {//Turmoil
		        p.requestGFX(658, 0);
		        p.requestAnim(4947, 0);
		        p.appearanceUpdateReq = true;
		        p.updateReq = true;
		}
				if (buttonId == 27) {//SoulSplit
		        p.requestAnim(14, 0);
		        p.requestGFX(1314, 0);
		        p.headIconPrayer = 4;  
		        p.appearanceUpdateReq = true;
		        p.updateReq = true;
		}
	break;
		case 619:
			if (buttonId == 29) { //mind altar
				p.frames.removeShownInterface(p);
				//p.teleportTo(2793, 4828, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
				p.frames.showChatboxInterface(p, 241);
				p.frames.animateInterfaceId(p, 9847, 241, 2);
				p.frames.setNPCId(p, 2258, 241, 2);
				p.frames.setString(p, "Mage of Zamorak", 241, 3);
				p.frames.setString(p, "I cannot let you go there due to missing mapdata.", 241, 4);
			}
			if (buttonId == 28) { //air altar
				p.frames.removeShownInterface(p);
				//p.teleportTo(2793, 4828, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
				p.frames.showChatboxInterface(p, 241);
				p.frames.animateInterfaceId(p, 9847, 241, 2);
				p.frames.setNPCId(p, 2258, 241, 2);
				p.frames.setString(p, "Mage of Zamorak", 241, 3);
				p.frames.setString(p, "I cannot let you go there due to missing mapdata.", 241, 4);
			}
			if (buttonId == 30) { //water altar
				p.frames.removeShownInterface(p);
				p.teleportTo(3494, 4831, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
			}
			if (buttonId ==	31) { //earth altar
				p.frames.removeShownInterface(p);
				p.teleportTo(2655, 4830, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
			}
			if (buttonId == 32) { //fire altar
				p.frames.removeShownInterface(p);
				p.teleportTo(2577, 4845, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
			}
			if (buttonId == 33) { //body altar
				p.frames.removeShownInterface(p);
				p.teleportTo(2521, 4834, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
			}
			if (buttonId == 34) { //cosmic altar
				p.frames.removeShownInterface(p);
				p.teleportTo(2162, 4833, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
			}
			if (buttonId == 35) { //chaos altar
				p.frames.removeShownInterface(p);
				p.teleportTo(2281, 4837, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
			}
			if (buttonId == 36) { //astral altar
				p.frames.removeShownInterface(p);
				p.teleportTo(2154, 3866, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
			}
			if (buttonId == 37) { //law altar
				p.frames.removeShownInterface(p);
				p.teleportTo(2464, 4818, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
			}
			if (buttonId == 38) { //death altar
				p.frames.removeShownInterface(p);
				p.teleportTo(2208, 4830, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
			}
			if (buttonId == 39) { //blood altar
				p.frames.removeShownInterface(p);
				p.frames.showChatboxInterface(p, 241);
				p.frames.animateInterfaceId(p, 9847, 241, 2);
				p.frames.setNPCId(p, 2258, 241, 2);
				p.frames.setString(p, "Mage of Zamorak", 241, 3);
				p.frames.setString(p, "I cannot let you go there due to missing mapdata.", 241, 4);
			}
			if (buttonId == 40) { //nature altar
				p.frames.removeShownInterface(p);
				p.teleportTo(2400, 4835, 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
			}
			if (buttonId == 41) { //soul altar
				p.frames.removeShownInterface(p);
				p.frames.showChatboxInterface(p, 241);
				p.frames.animateInterfaceId(p, 9847, 241, 2);
				p.frames.setNPCId(p, 2258, 241, 2);
				p.frames.setString(p, "Mage of Zamorak", 241, 3);
				p.frames.setString(p, "I cannot let you go there due to missing mapdata.", 241, 4);
			}
		break;
				case 574:
					if (buttonId == 17) {
					p.teleportTo(3090, 3956, 0, 4, 0, 8939, 8941, 1678, 0, 1679, 0);
					p.frames.removeShownInterface(p);
				} else {
					if (buttonId == 18) {
					p.frames.removeShownInterface(p);
					}
				}
			break;
					case 771:
if (buttonId == 49) {
p.look[0] = 3;
p.look[1] = 10;
p.look[2] = 18;
p.look[3] = 26;
p.look[4] = 33;
p.look[5] = 36;
p.look[6] = 42;
p.gender = 0;
}
if (buttonId == 52) {
p.look[0] = 48; // Hair
p.look[1] = 1000; // Beard
p.look[2] = 57; // Torso
p.look[3] = 64; // Arms
p.look[4] = 68; // Bracelets
p.look[5] = 77; // Legs
p.look[6] = 80; // Shoes
p.gender = 1;
}
if (buttonId == 92 && p.gender < 1) {
p.look[0] = p.look[0] - 1;
if (p.look[0] < 0)
p.look[0] = 260;
if (p.look[0] > 8 && p.look[0] < 91)
p.look[0] = 8;
if (p.look[0] > 97 && p.look[0] < 246)
p.look[0] = 97;
if (p.look[0] > 260 && p.look[0] < 1000)
p.look[0] = 260;
}
if (buttonId == 92 && p.gender > 0) {
p.look[0] = p.look[0] - 1;
if (p.look[0] < 45)
p.look[0] = 280;
if (p.look[0] > 55 && p.look[0] < 135)
p.look[0] = 55;
if (p.look[0] > 144 && p.look[0] < 269)
p.look[0] = 144;
if (p.look[0] > 280 && p.look[0] < 1000)
p.look[0] = 45;
}
if (buttonId == 93 && p.gender < 1) {
p.look[0] = p.look[0] + 1;
if (p.look[0] > 8 && p.look[0] < 91)
p.look[0] = 91;
if (p.look[0] > 97 && p.look[0] < 246)
p.look[0] = 246;
if (p.look[0] > 260 && p.look[0] < 1000)
p.look[0] = 0;
}
if (buttonId == 93 && p.gender > 0) {
p.look[0] = p.look[0] + 1;
if (p.look[0] > 55 && p.look[0] < 135)
p.look[0] = 135;
if (p.look[0] > 144 && p.look[0] < 269)
p.look[0] = 269;
if (p.look[0] > 280 && p.look[0] < 1000)
p.look[0] = 45;
}
if (buttonId == 97) {
p.look[1] = p.look[1] - 1;
if (p.look[1] < 10)
p.look[1] = 17;
}
if (buttonId == 98) {
p.look[1] = p.look[1] + 1;
if (p.look[1] > 17)
p.look[1] = 10;

}
if (buttonId == 100) {
p.color[0] = 20;
}
if (buttonId == 101) {
p.color[0] = 19;
}
if (buttonId == 102) {
p.color[0] = 10;
}
if (buttonId == 103) {
p.color[0] = 18;
}
if (buttonId == 104) {
p.color[0] = 4;
}
if (buttonId == 105) {
p.color[0] = 5;
}
if (buttonId == 106) {
p.color[0] = 15;
}
if (buttonId == 107) {
p.color[0] = 7;
}
if (buttonId == 108) {
p.color[0] = 26;
}
if (buttonId == 109) {
p.color[0] = 6;
}
if (buttonId == 110) {
p.color[0] = 21;
}
if (buttonId == 111) {
p.color[0] = 9;
}
if (buttonId == 112) {
p.color[0] = 22;
}
if (buttonId == 113) {
p.color[0] = 17;
}
if (buttonId == 114) {
p.color[0] = 8;
}
if (buttonId == 115) {
p.color[0] = 16;
}
if (buttonId == 116) {
p.color[0] = 11;
}
if (buttonId == 117) {
p.color[0] = 24;
}
if (buttonId == 118) {
p.color[0] = 23;
}
if (buttonId == 119) {
p.color[0] = 3;
}
if (buttonId == 120) {
p.color[0] = 2;
}
if (buttonId == 121) {
p.color[0] = 1;
}
if (buttonId == 122) {
p.color[0] = 14;
}
if (buttonId == 123) {
p.color[0] = 13;
}
if (buttonId == 124) {
p.color[0] = 12;
}
if (buttonId == 158) {
p.color[4] = 7;
}
if (buttonId == 151) {
p.color[4] = 8;
}
if (buttonId == 152) {
p.color[4] = 1;
}
if (buttonId == 153) {
p.color[4] = 2;
}
if (buttonId == 154) {
p.color[4] = 3;
}
if (buttonId == 155) {
p.color[4] = 4;
}
if (buttonId == 156) {
p.color[4] = 5;
}
if (buttonId == 157) {
p.color[4] = 6;
}
	    if (buttonId == 307) { //BOOT-COLOR
				p.color[3] = 6;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 308) { //BOOT-COLOR
				p.color[3] = 1;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 309) { //BOOT-COLOR
				p.color[3] = 2;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 310) { //BOOT-COLOR
				p.color[3] = 3;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 311) { //BOOT-COLOR
				p.color[3] = 4;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 312) { //BOOT-COLOR
				p.color[3] = 5;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }

	    if (buttonId == 263) { //LEG-COLOR
				p.color[2] = 0;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 258) { //LEG-COLOR
				p.color[2] = 1;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 275) { //LEG-COLOR
				p.color[2] = 2;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 251) { //LEG-COLOR
				p.color[2] = 3;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 271) { //LEG-COLOR
				p.color[2] = 4;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 257) { //LEG-COLOR
				p.color[2] = 5;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 272) { //LEG-COLOR
				p.color[2] = 6;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 255) { //LEG-COLOR
				p.color[2] = 7;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 265) { //LEG-COLOR
				p.color[2] = 8;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 262) { //LEG-COLOR
				p.color[2] = 9;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 259) { //LEG-COLOR
				p.color[2] = 10;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 268) { //LEG-COLOR
				p.color[2] = 11;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 254) { //LEG-COLOR
				p.color[2] = 12;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 253) { //LEG-COLOR
				p.color[2] = 13;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 260) { //LEG-COLOR
				p.color[2] = 14;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 267) { //LEG-COLOR
				p.color[2] = 15;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 276) { //LEG-COLOR
				p.color[2] = 16;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 274) { //LEG-COLOR
				p.color[2] = 17;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 273) { //LEG-COLOR
				p.color[2] = 18;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 256) { //LEG-COLOR
				p.color[2] = 19;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 266) { //LEG-COLOR
				p.color[2] = 20;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 264) { //LEG-COLOR
				p.color[2] = 21;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 252) { //LEG-COLOR
				p.color[2] = 22;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 250) { //LEG-COLOR
				p.color[2] = 23;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 249) { //LEG-COLOR
				p.color[2] = 24;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 261) { //LEG-COLOR
				p.color[2] = 25;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 248) { //LEG-COLOR
				p.color[2] = 26;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 270) { //LEG-COLOR
				p.color[2] = 27;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 269) { //LEG-COLOR
				p.color[2] = 28;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }

	    if (buttonId == 198) { //TOP-COLOR
				p.color[1] = 0;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 216) { //TOP-COLOR
				p.color[1] = 1;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 191) { //TOP-COLOR
				p.color[1] = 2;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 212) { //TOP-COLOR
				p.color[1] = 3;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 197) { //TOP-COLOR
				p.color[1] = 4;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 213) { //TOP-COLOR
				p.color[1] = 5;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 195) { //TOP-COLOR
				p.color[1] = 6;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 206) { //TOP-COLOR
				p.color[1] = 7;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 202) { //TOP-COLOR
				p.color[1] = 8;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 199) { //TOP-COLOR
				p.color[1] = 9;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 209) { //TOP-COLOR
				p.color[1] = 10;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 194) { //TOP-COLOR
				p.color[1] = 11;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 193) { //TOP-COLOR
				p.color[1] = 12;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 200) { //TOP-COLOR
				p.color[1] = 13;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 208) { //TOP-COLOR
				p.color[1] = 14;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 203) { //TOP-COLOR
				p.color[1] = 15;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 217) { //TOP-COLOR
				p.color[1] = 16;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 215) { //TOP-COLOR
				p.color[1] = 17;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 214) { //TOP-COLOR
				p.color[1] = 18;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 196) { //TOP-COLOR
				p.color[1] = 19;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 207) { //TOP-COLOR
				p.color[1] = 20;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 205) { //TOP-COLOR
				p.color[1] = 21;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 192) { //TOP-COLOR
				p.color[1] = 22;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 190) { //TOP-COLOR
				p.color[1] = 23;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 189) { //TOP-COLOR
				p.color[1] = 24;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 201) { //TOP-COLOR
				p.color[1] = 25;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 204) { //TOP-COLOR
				p.color[1] = 26;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 211) { //TOP-COLOR
				p.color[1] = 27;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }
	    if (buttonId == 210) { //TOP-COLOR
				p.color[1] = 28;
				p.appearanceUpdateReq = true;
				p.updateReq = true;
	    }

	    if (buttonId == 362) {
			if (p.firstLog == 0) {
				p.disconnected[0] = false;
				p.firstLog = 1;
				p.updateReq = true;
				p.appearanceUpdateReq = true;
				p.frames.removeShownInterface(p);
				p.frames.setInterfaces(p);
				p.frames.sendMessage(p, "<col=0066CC>And so your adventure begins...");
			} else if (p.firstLog == 1) {
				p.updateReq = true;
				p.appearanceUpdateReq = true;
				p.frames.removeShownInterface(p);
				p.frames.sendMessage(p, "<col=006600>Character Update Complete.");
			}
	     }

				p.appearanceUpdateReq = true;
				p.updateReq = true;
				
               break;
		            case 105:
            switch(buttonId) {
                case 194:
                Object[] o = new Object[]{"Grand Exchange Item Search"};
                    p.frames.setGeSearch(p, o);
                break;
            }
            p.GrandExchange.handleButtons(buttonId);
            break;

        case 107:
                if(p.items[buttonId2] == 995) {
                    p.frames.sendMessage(p, "You can't offer money!");
                    return;
                }
                p.GrandExchange.offerItem(buttonId2);
            break;
			
		    case 335:
            case 334:
            case 336:
                p.pTrade.buttons.handleButton(interfaceId, packetId, buttonId, buttonId2);
            break;
		case 561:
		if (buttonId == 17) {
			p.frames.removeShownInterface(p);
			p.homeTeleport(3508, 9493);
			}
		break;
		case 589:
        if(buttonId == 9) {
        p.frames.showInterface(p, 590);
        }
        break;
		case 657:
		if (buttonId == 18) {
			p.frames.removeShownInterface(p);
			//p.inHighBounty = true;			p.resetAnimTimer = 7;
			p.teleportTo(3180, 3708, 12, 4, 0, 8858, 8859, 6000, 0, 6000, 0);
			p.frames.sendMessage(p, "You enter the crater. <col=ff0000>You have been warned!");
		}
		break;
		case 751:
		if (buttonId == 27) {
            p.frames.showInterface(p, 553);
		}
		break;
		case 382:
		if (buttonId == 18) {
			p.jumpDelay = 3;
			p.frames.removeShownInterface(p);
			p.frames.playSound(p, 2462, 1, 0);
			p.jumpUpdateReq = false;
            p.reqWalkQueue(p.absX, p.clickY + 2);
}
break;
		case 378:
if (buttonId == 140) {
if(p.Resizable == false && p.firstLog == 0) {
p.frames.setWindowPane(p, 548);
p.frames.setPlayerHead(p, 771, 79);
//p.frames.setInterfaces(p);
//p.frames.setInterface(p, 1, 548, 2, 771);
//p.frames.setInterface(p, 1, 548, 3, 771);
p.frames.showInterface(p, 771);
}
else if(p.Resizable == true && p.firstLog == 0) {
p.frames.setWindowPane(p, 549);
p.frames.setPlayerHead(p, 771, 79);
p.frames.setInterfaces(p);
//p.frames.setInterface(p, 1, 548, 2, 771);
//p.frames.setInterface(p, 1, 548, 3, 771);
p.frames.showInterface(p, 771);
}
else if(p.Resizable == false && p.firstLog == 1) {
p.frames.setWindowPane(p, 548);
p.frames.setInterfaces(p);
}
else if(p.Resizable == true && p.firstLog == 1) {
p.frames.setWindowPane(p, 549);
p.frames.setInterfaces(p);
}
}
break;

	case 259:
		if (buttonId == 2) {
			quest.addQuestScroll();
			quest.setQuestId(1);
		}
	break;

	case 662:
		/**
		 * Summoning IDS
		 */
		if (buttonId == 50) {
			if (p.summonedFamiliar)
				Server.engine.rebuildNPCs();
			if (p.summonedFamiliar)
				p.callFamiliar = true;
		}
		if (buttonId == 52) {
			if (p.summonedFamiliar)
				p.familiarDissMiss = true;
		}
	break;
        case 387:
            /*
             * Equipment tab.
             */
            if (buttonId == 55) {
                p.frames.showInterface(p, 667);
                p.frames.setInventory(p, 149);
				p.frames.setString(p, "0kg", 667, 38);
                p.frames.setItems(p, -1, 64209, 93, p.items, p.itemsN);
                p.frames.setItems(p, -1, 64208, 94, p.equipment, p.equipmentN);
                p.setEquipmentBonus();
            }
			if (buttonId == 52) {
				p.frames.showInterface(p, 102);
				p.frames.setString(p, "The normal amount of items kept is three.", 102, 27);
				p.frames.setString(p, "Max items kept on death:", 102, 28);
			}
            break;
	case 271:
            //Misc.println("[" + p.username + "] Unhandled button: " + interfaceId + ", " + buttonId + ":" + buttonId2);

	    if (buttonId == 5) {
		if (!p.thickSkin) {
			p.frames.setConfig(p, 83, 1);
			if (p.drainDelay > 0) {
				p.drainDelay = p.drainDelay;
			} else {
				p.drainDelay = 8;
			}
			p.usingPrayer = true;
			p.thickSkin = true;
			p.rockSkin = false;
			p.steelSkin = false;
			p.frames.setConfig(p, 92, 0);
			p.frames.setConfig(p, 86, 0);
		} else {
			p.frames.setConfig(p, 83, 0);
			p.frames.playSound(p, 2663, 1, 0);
			p.usingPrayer = false;
			p.thickSkin = false;
		}
	    }
	    if (buttonId == 15) {
		if (!p.rockSkin) {
			p.frames.setConfig(p, 86, 1);
			if (p.drainDelay > 0) {
				p.drainDelay = p.drainDelay;
			} else {
				p.drainDelay = 8;
			}
			p.usingPrayer = true;
			p.rockSkin = true;
			p.thickSkin = false;
			p.steelSkin = false;
			p.frames.setConfig(p, 92, 0);
			p.frames.setConfig(p, 83, 0);
		} else {
			p.frames.setConfig(p, 86, 0);
			p.frames.playSound(p, 2663, 1, 0);
			p.usingPrayer = false;
			p.rockSkin = false;
		}
	    }
	    if (buttonId == 31) {
		if (!p.steelSkin) {
			p.frames.setConfig(p, 92, 1);
			if (p.drainDelay > 0) {
				p.drainDelay = p.drainDelay;
			} else {
				p.drainDelay = 8;
			}
			p.usingPrayer = true;
			p.steelSkin = true;
			p.thickSkin = false;
			p.rockSkin = false;
			p.frames.setConfig(p, 86, 0);
			p.frames.setConfig(p, 83, 0);
		} else {
			p.frames.setConfig(p, 92, 0);
			p.frames.playSound(p, 2663, 1, 0);
			p.usingPrayer = false;
			p.steelSkin = false;
		}
	    }
	    if (buttonId == 9) {
		if (!p.clarity) {
			p.frames.setConfig(p, 85, 1);
			if (p.drainDelay > 0) {
				p.drainDelay = p.drainDelay;
			} else {
				p.drainDelay = 8;
			}
			p.usingPrayer = true;
			p.clarity = true;
			p.incredibleReflex = false;
			p.improvedReflex = false;
			p.frames.setConfig(p, 88, 0);
			p.frames.setConfig(p, 94, 0);
			p.frames.playSound(p, 2664, 1, 0);
		} else {
			p.frames.setConfig(p, 85, 0);
			p.frames.playSound(p, 2663, 1, 0);
			p.usingPrayer = false;
			p.clarity = false;
		}
	    }
	    if (buttonId == 19) {
		if (!p.improvedReflex) {
			p.frames.setConfig(p, 88, 1);
			if (p.drainDelay > 0) {
				p.drainDelay = p.drainDelay;
			} else {
				p.drainDelay = 8;
			}
			p.usingPrayer = true;
			p.improvedReflex = true;
			p.incredibleReflex = false;
			p.clarity = false;
			p.frames.setConfig(p, 85, 0);
			p.frames.setConfig(p, 94, 0);
			p.frames.playSound(p, 2662, 1, 0);
		} else {
			p.frames.setConfig(p, 88, 0);
			p.frames.playSound(p, 2663, 1, 0);
			p.usingPrayer = false;
			p.improvedReflex = false;
		}
	    }
	    if (buttonId == 35) {
		if (!p.incredibleReflex) {
			p.frames.setConfig(p, 94, 1);
			if (p.drainDelay > 0) {
				p.drainDelay = p.drainDelay;
			} else {
				p.drainDelay = 8;
			}
			p.usingPrayer = true;
			p.incredibleReflex = true;
			p.improvedReflex = false;
			p.clarity = false;
			p.frames.setConfig(p, 85, 0);
			p.frames.setConfig(p, 88, 0);
			p.frames.playSound(p, 2667, 1, 0);
		} else {
			p.frames.setConfig(p, 94, 0);
			p.frames.playSound(p, 2663, 1, 0);
			p.usingPrayer = false;
			p.incredibleReflex = false;
		}
	    }
	    if (buttonId == 43) {
		if (!p.eagleEyePrayer) {
			p.frames.setConfig(p, 866, 1);
			if (p.drainDelay > 0) {
				p.drainDelay = p.drainDelay;
			} else {
				p.drainDelay = 8;
			}
			p.usingPrayer = true;
			p.eagleEyePrayer = true;
			p.mysticMightPrayer = false;
			p.frames.setConfig(p, 867, 0);
			p.frames.playSound(p, 2666, 1, 0);
		} else {
			p.frames.setConfig(p, 866, 0);
			p.frames.playSound(p, 2663, 1, 0);
			p.usingPrayer = false;
			p.eagleEyePrayer = false;
		}
	    }
	    if (buttonId == 45) {
		if (!p.mysticMightPrayer) {
			p.frames.setConfig(p, 867, 1);
			if (p.drainDelay > 0) {
				p.drainDelay = p.drainDelay;
			} else {
				p.drainDelay = 8;
			}
			p.usingPrayer = true;
			p.mysticMightPrayer = true;
			p.eagleEyePrayer = false;
			p.frames.setConfig(p, 866, 0);
			p.frames.playSound(p, 2669, 1, 0);
		} else {
			p.frames.setConfig(p, 867, 0);
			p.frames.playSound(p, 2663, 1, 0);
			p.usingPrayer = false;
			p.mysticMightPrayer = false;
		}
	    }
	    if (buttonId == 7) {
		if (!p.burstOfStr) {
			p.frames.setConfig(p, 84, 1);
			if (p.drainDelay > 0) {
				p.drainDelay = p.drainDelay;
			} else {
				p.drainDelay = 8;
			}
			p.usingPrayer = true;
			p.burstOfStr = true;
			p.superHumanStr = false;
			p.ultimateStr = false;
			p.frames.setConfig(p, 87, 0);
			p.frames.setConfig(p, 93, 0);
			p.frames.playSound(p, 2689, 1, 0);
		} else {
			p.frames.setConfig(p, 84, 0);
			p.frames.playSound(p, 2663, 1, 0);
			p.usingPrayer = false;
			p.burstOfStr = false;
		}
	    }
	    if (buttonId == 17) {
		if (!p.superHumanStr) {
			p.frames.setConfig(p, 87, 1);
			if (p.drainDelay > 0) {
				p.drainDelay = p.drainDelay;
			} else {
				p.drainDelay = 8;
			}
			p.usingPrayer = true;
			p.superHumanStr = true;
			p.burstOfStr = false;
			p.ultimateStr = false;
			p.frames.setConfig(p, 84, 0);
			p.frames.setConfig(p, 93, 0);
			p.frames.playSound(p, 2690, 1, 0);
		} else {
			p.frames.setConfig(p, 87, 0);
			p.frames.playSound(p, 2663, 1, 0);
			p.usingPrayer = false;
			p.superHumanStr = false;
		}
	    }
	    if (buttonId == 33) {
		if (!p.ultimateStr) {
			p.frames.setConfig(p, 93, 1);
			if (p.drainDelay > 0) {
				p.drainDelay = p.drainDelay;
			} else {
				p.drainDelay = 8;
			}
			p.usingPrayer = true;
			p.ultimateStr = true;
			p.burstOfStr = false;
			p.superHumanStr = false;
			p.frames.setConfig(p, 84, 0);
			p.frames.setConfig(p, 87, 0);
			p.frames.playSound(p, 2691, 1, 0);
		} else {
			p.frames.setConfig(p, 93, 0);
			p.frames.playSound(p, 2663, 1, 0);
			p.usingPrayer = false;
			p.ultimateStr = false;
		}
	    }
	    if (buttonId == 51) {
		if (p.skillLvl[5] <= 0) {
			p.resetPrayer();
			p.frames.sendMessage(p, "You are out of prayer points. Please restore them at an altar.");
			p.appearanceUpdateReq = true;
			p.updateReq = true;
			return;
		}
		if (!p.smitePrayer) {
			p.frames.setConfig(p, 95, 0);
			p.frames.setConfig(p, 96, 0);
			p.frames.setConfig(p, 97, 0);
			p.frames.setConfig(p, 98, 0);
			p.frames.setConfig(p, 99, 0);
			p.frames.setConfig(p, 100, 1);
			p.magicPrayer = false;
			p.rangedPrayer = false;
			p.meleePrayer = false;
			p.redempPrayer = false;
			p.retriPrayer = false;
			if (p.drainDelay > 0) {
				p.drainDelay = p.drainDelay;
			} else {
				p.drainDelay = 8;
			}
			p.usingPrayer = true;
			p.headIconPrayer = 4;
			p.smitePrayer = true;
	 	} else {
			p.frames.setConfig(p, 100, 0);
			p.usingPrayer = false;
			p.headIconPrayer = -1;
			p.smitePrayer = false;
		}
		p.appearanceUpdateReq = true;
		p.updateReq = true;
	    }
	    if (buttonId == 49) {
		if (p.skillLvl[5] <= 0) {
			p.resetPrayer();
			p.frames.sendMessage(p, "You are out of prayer points. Please restore them at an altar.");
			p.appearanceUpdateReq = true;
			p.updateReq = true;
			return;
		}
		 if (!p.redempPrayer) {
			p.frames.setConfig(p, 95, 0);
			p.frames.setConfig(p, 96, 0);
			p.frames.setConfig(p, 97, 0);
			p.frames.setConfig(p, 98, 0);
			p.frames.setConfig(p, 99, 1);
			p.frames.setConfig(p, 100, 0);
			p.magicPrayer = false;
			p.rangedPrayer = false;
			p.meleePrayer = false;
			p.retriPrayer = false;
			p.smitePrayer = false;
			if (p.drainDelay > 0) {
				p.drainDelay = p.drainDelay;
			} else {
				p.drainDelay = 8;
			}
			p.usingPrayer = true;
			p.headIconPrayer = 5;
			p.redempPrayer = true;
		} else {
			p.frames.setConfig(p, 99, 0);
			p.usingPrayer = false;
			p.headIconPrayer = -1;
			p.redempPrayer = false;
		}
		p.appearanceUpdateReq = true;
		p.updateReq = true;
	    }
	    if (buttonId == 47) {
		if (p.skillLvl[5] <= 0) {
			p.resetPrayer();
			p.frames.sendMessage(p, "You are out of prayer points. Please restore them at an altar.");
			p.appearanceUpdateReq = true;
			p.updateReq = true;
			return;
		}
		 if (!p.retriPrayer) {
			p.frames.setConfig(p, 95, 0);
			p.frames.setConfig(p, 96, 0);
			p.frames.setConfig(p, 97, 0);
			p.frames.setConfig(p, 98, 1);
			p.frames.setConfig(p, 99, 0);
			p.frames.setConfig(p, 100, 0);
			p.magicPrayer = false;
			p.rangedPrayer = false;
			p.meleePrayer = false;
			if (p.drainDelay > 0) {
				p.drainDelay = p.drainDelay;
			} else {
				p.drainDelay = 8;
			}
			p.usingPrayer = true;
			p.headIconPrayer = 3;
			p.retriPrayer = true;
		} else {
			p.frames.setConfig(p, 98, 0);
			p.usingPrayer = false;
			p.headIconPrayer = -1;
			p.retriPrayer = false;
		}
		p.appearanceUpdateReq = true;
		p.updateReq = true;
	    }
	    if (buttonId == 41) {
		if (p.skillLvl[5] <= 0) {
			p.resetPrayer();
			p.frames.sendMessage(p, "You are out of prayer points. Please restore them at an altar.");
			p.appearanceUpdateReq = true;
			p.updateReq = true;
			return;
		}
		 if (!p.meleePrayer) {
			p.frames.setConfig(p, 95, 0);
			p.frames.setConfig(p, 96, 0);
			p.frames.setConfig(p, 97, 1);
			p.frames.setConfig(p, 98, 0);
			p.frames.setConfig(p, 99, 0);
			p.frames.setConfig(p, 100, 0);
			p.magicPrayer = false;
			p.rangedPrayer = false;
			p.redempPrayer = false;
			p.retriPrayer = false;
			p.smitePrayer = false;
			if (p.drainDelay > 0) {
				p.drainDelay = p.drainDelay;
			} else {
				p.drainDelay = 8;
			}
			p.usingPrayer = true;
			p.headIconPrayer = 0;
			p.meleePrayer = true;
		} else {
			p.frames.setConfig(p, 97, 0);
			p.usingPrayer = false;
			p.headIconPrayer = -1;
			p.meleePrayer = false;
		}
		p.appearanceUpdateReq = true;
		p.updateReq = true;
	    }
	    if (buttonId == 39) {
		if (p.skillLvl[5] <= 0) {
			p.resetPrayer();
			p.frames.sendMessage(p, "You are out of prayer points. Please restore them at an altar.");
			p.appearanceUpdateReq = true;
			p.updateReq = true;
			return;
		}
		 if (!p.rangedPrayer) {
			p.frames.setConfig(p, 95, 0);
			p.frames.setConfig(p, 96, 1);
			p.frames.setConfig(p, 97, 0);
			p.frames.setConfig(p, 98, 0);
			p.frames.setConfig(p, 99, 0);
			p.frames.setConfig(p, 100, 0);
			p.magicPrayer = false;
			p.meleePrayer = false;
			p.redempPrayer = false;
			p.retriPrayer = false;
			p.smitePrayer = false;
			if (p.drainDelay > 0) {
				p.drainDelay = p.drainDelay;
			} else {
				p.drainDelay = 8;
			}
			p.usingPrayer = true;
			p.headIconPrayer = 1;
			p.rangedPrayer = true;
		} else {
			p.frames.setConfig(p, 96, 0);
			p.usingPrayer = false;
			p.headIconPrayer = -1;
			p.rangedPrayer = false;
		}
		p.appearanceUpdateReq = true;
		p.updateReq = true;
	    }
	    if (buttonId == 37) {
		if (p.skillLvl[5] <= 0) {
			p.resetPrayer();
			p.frames.sendMessage(p, "You are out of prayer points. Please restore them at an altar.");
			p.appearanceUpdateReq = true;
			p.updateReq = true;
			return;
		}
		 if (!p.magicPrayer) {
			p.frames.setConfig(p, 95, 1);
			p.frames.setConfig(p, 96, 0);
			p.frames.setConfig(p, 97, 0);
			p.frames.setConfig(p, 98, 0);
			p.frames.setConfig(p, 99, 0);
			p.frames.setConfig(p, 100, 0);
			p.rangedPrayer = false;
			p.meleePrayer = false;
			p.redempPrayer = false;
			p.retriPrayer = false;
			p.smitePrayer = false;
			if (p.drainDelay > 0) {
				p.drainDelay = p.drainDelay;
			} else {
				p.drainDelay = 8;
			}
			p.usingPrayer = true;
			p.headIconPrayer = 2;
			p.magicPrayer = true;
		} else {
			p.frames.setConfig(p, 95, 0);
			p.usingPrayer = false;
			p.headIconPrayer = -1;
			p.magicPrayer = false;
		}
		p.appearanceUpdateReq = true;
		p.updateReq = true;
	     }
	    if (buttonId == 55) { /* Chilvary */
		if (p.skillLvl[5] <= 0) {
			p.resetPrayer();
			p.frames.sendMessage(p, "You are out of prayer points. Please restore them at an altar.");
			p.appearanceUpdateReq = true;
			p.updateReq = true;
			return;
		}
		if (!p.chilvaryPrayer) {
			p.frames.setConfig(p, 1052, 1);
			p.frames.setConfig(p, 1053, 0);
			p.pietyPrayer = false;
			p.chilvaryPrayer = true;
			if (p.drainDelay > 0) {
				p.drainDelay = p.drainDelay;
			} else {
				p.drainDelay = 8;
			}
			p.usingPrayer = true;
		} else {
			p.usingPrayer = false;
			p.chilvaryPrayer = false;
			p.frames.setConfig(p, 1052, 0);
		}
	    }
	    if (buttonId == 57) { /* Piety */
		if (p.skillLvl[5] <= 0) {
			p.resetPrayer();
			p.frames.sendMessage(p, "You are out of prayer points. Please restore them at an altar.");
			p.appearanceUpdateReq = true;
			p.updateReq = true;
			return;
		}
		if (!p.pietyPrayer) {
			p.frames.setConfig(p, 1052, 0);
			p.frames.setConfig(p, 1053, 1);
			p.pietyPrayer = true;
			p.chilvaryPrayer = false;
			if (p.drainDelay > 0) {
				p.drainDelay = p.drainDelay;
			} else {
				p.drainDelay = 8;
			}
			p.usingPrayer = true;
		} else {
			p.usingPrayer = false;
			p.pietyPrayer = false;
			p.frames.setConfig(p, 1053, 0);
		}
	    }
	break;
        case 750:
            /*
             * Running button next to minimap.
             */
        case 261:
		if (buttonId == 3) {
        p.splitChat = !p.splitChat;
        p.frames.setConfig(p, 287, p.splitChat ? 1 : 0);
    if(p.splitChat) {
        p.stream.createFrameVarSizeWord(152);
        p.stream.writeString("s");
        p.stream.writeDWord(83);
        p.stream.endFrameVarSize();
    }
}
            /*
             * Settings tab.
             */
            if (buttonId == 1) {
                if (!p.isRunning) {
                    p.isRunning = true;
                    p.frames.setConfig(p, 173, 1);
                } else {
                    p.isRunning = false;
                    p.frames.setConfig(p, 173, 0);
                }
            } else if (buttonId == 14) {
                p.frames.showInterface(p, 742);
            } else if (buttonId == 16) {
                p.frames.showInterface(p, 743);
	    } else if (buttonId == 2) {
		if (!p.Chat) {
			p.Chat = true;
			p.frames.setConfig(p, 171, 1);
		} else {
			p.Chat = false;
			p.frames.setConfig(p, 171, 0);
		}
	    } else if (buttonId == 3) {
		if (!p.Split) {
			p.Split = true;
			p.frames.setConfig(p, 287, 1);
		} else {
			p.Split = false;
			p.frames.setConfig(p, 287, 0);
		}
	    } else if (buttonId == 4) {
		if (!p.Mouse) {
			p.Mouse = true;
			p.frames.setConfig(p, 170, 1);
		} else {
			p.Mouse = false;
			p.frames.setConfig(p, 170, 0);
		}
	    } else if (buttonId == 5) {
		if (!p.Aid) {
			p.Aid = true;
			p.frames.setConfig(p, 427, 1);
		} else {
			p.Aid = false;
			p.frames.setConfig(p, 427, 0);
		}
	    }
            break;

	case 192:
		if (buttonId == 0) {
		if (p.deathDelay > 0 || p.randomDelay > 0 || p.attackingPlayer || p.isDead || p.combatDelay > 0 || p.clanWarsFightArea())
			return;
		if (p.wildLevel >= 20 && Server.engine.wildernessArea(p.absX, p.absY) && !p.inClan()) {
			p.frames.sendMessage(p, "A magical force is stopping you from teleporting.");
			return;
		}
		if (p.inJadCave())
		p.getFightClass().deleteFightNPCs();
		p.frames.playSound(p, 200, 1, 0);
            		p.setCoords(3224, 3222, 0);
		p.frames.removeOverlay(p);
		p.frames.sendMessage(p, "Welcome home.");
	    }

	Magic.modernMagicAB(p, buttonId);
	break;
	case 193:
		Magic.ancientMagicAB(p, buttonId);
		break;

	case 116:
	    /**
	     * Close interface (116)
	     */
	    if (buttonId == 0) {
			p.frames.removeOverlay(p);
			p.frames.removeShownInterface(p);
	    }
			break;

	case 429:
	    /*
	     * NPC Contact
	     */

	    if (buttonId == 10) {
   			p.frames.showChatboxInterface(p, 241);
                	p.frames.animateInterfaceId(p, 9847, 241, 2);
                	p.frames.setNPCId(p, 4362, 241, 2);
                	p.frames.setString(p, "Honest Jimmy", 241, 3);
                	p.frames.setString(p, "Good day "+p.username+", how may I be of service?", 241, 4);
			p.removeRunes("npccontact");
	    }
	    if (buttonId == 11) {
   			p.frames.showChatboxInterface(p, 241);
                	p.frames.animateInterfaceId(p, 9847, 241, 2);
                	p.frames.setNPCId(p, 3108, 241, 2);
                	p.frames.setString(p, "Bert", 241, 3);
                	p.frames.setString(p, "Hello "+p.username+", what did you contact me for?", 241, 4);
			p.removeRunes("npccontact");
	    }
	    if (buttonId == 12) {
   			p.frames.showChatboxInterface(p, 241);
                	p.frames.animateInterfaceId(p, 9847, 241, 2);
                	p.frames.setNPCId(p, 1375, 241, 2);
                	p.frames.setString(p, "Advisor Ghrim", 241, 3);
                	p.frames.setString(p, "Hello "+p.username+", what service do you require of me?", 241, 4);
			p.removeRunes("npccontact");
	    }
	    if (buttonId == 13) {
   			p.frames.showChatboxInterface(p, 241);
                	p.frames.animateInterfaceId(p, 9847, 241, 2);
                	p.frames.setNPCId(p, 70, 241, 2);
                	p.frames.setString(p, "Turael", 241, 3);
                	p.frames.setString(p, "Hello "+p.username+", do you need another slayer task?", 241, 4);
			p.removeRunes("npccontact");
	    }
	    if (buttonId == 14) {
   			p.frames.showChatboxInterface(p, 241);
                	p.frames.animateInterfaceId(p, 9847, 241, 2);
                	p.frames.setNPCId(p, 1526, 241, 2);
                	p.frames.setString(p, "Lanthus", 241, 3);
                	p.frames.setString(p, "Hello "+p.username+", did you need me?", 241, 4);
			p.removeRunes("npccontact");
	    }
	    if (buttonId == 15) {
   			p.frames.showChatboxInterface(p, 241);
                	p.frames.animateInterfaceId(p, 9847, 241, 2);
                	p.frames.setNPCId(p, 7780, 241, 2);
                	p.frames.setString(p, "Sumona", 241, 3);
                	p.frames.setString(p, "Hello "+p.username+", what do you need me for?", 241, 4);
			p.removeRunes("npccontact");
	    }
	    if (buttonId == 16) {
   			p.frames.showChatboxInterface(p, 241);
                	p.frames.animateInterfaceId(p, 9847, 241, 2);
                	p.frames.setNPCId(p, 1596, 241, 2);
                	p.frames.setString(p, "Mazchna", 241, 3);
                	p.frames.setString(p, "Hello "+p.username+", do you need another slayer task?", 241, 4);
			p.removeRunes("npccontact");
			p.removeRunes("npccontact");
	    }
	    if (buttonId == 17) {
   			p.frames.showChatboxInterface(p, 241);
                	p.frames.animateInterfaceId(p, 9847, 241, 2);
                	p.frames.setNPCId(p, 1599, 241, 2);
                	p.frames.setString(p, "Duradel", 241, 3);
                	p.frames.setString(p, "Hello "+p.username+", do you need another slayer task?", 241, 4);
			p.removeRunes("npccontact");
			p.removeRunes("npccontact");
	    }
	    if (buttonId == 18) {
   			p.frames.showChatboxInterface(p, 241);
                	p.frames.animateInterfaceId(p, 9847, 241, 2);
                	p.frames.setNPCId(p, 1597, 241, 2);
                	p.frames.setString(p, "Vannaka", 241, 3);
                	p.frames.setString(p, "Hello "+p.username+", do you need another slayer task?", 241, 4);
			p.removeRunes("npccontact");
	    }
	    if (buttonId == 19) {
   			p.frames.showChatboxInterface(p, 241);
                	p.frames.animateInterfaceId(p, 9847, 241, 2);
                	p.frames.setNPCId(p, 463, 241, 2);
                	p.frames.setString(p, "Murphy", 241, 3);
                	p.frames.setString(p, "Hello "+p.username+", did you need me to sail you anywhere?", 241, 4);
			p.removeRunes("npccontact");
	    }
	    if (buttonId == 20) {
   			p.frames.showChatboxInterface(p, 241);
                	p.frames.animateInterfaceId(p, 9847, 241, 2);
                	p.frames.setNPCId(p, 1598, 241, 2);
                	p.frames.setString(p, "Chaeldar", 241, 3);
                	p.frames.setString(p, "Hello "+p.username+", do you need another slayer task?", 241, 4);
			p.removeRunes("npccontact");
	    }
	    if (buttonId == 22) {
   			p.frames.showChatboxInterface(p, 241);
                	p.frames.animateInterfaceId(p, 9847, 241, 2);
                	p.frames.setNPCId(p, 5893, 241, 2);
                	p.frames.setString(p, "Cyrisus", 241, 3);
                	p.frames.setString(p, "Hello "+p.username+", do you need me?", 241, 4);
			p.removeRunes("npccontact");
	    }
	    if (buttonId == 37) {
			p.frames.removeOverlay(p);
			p.frames.removeShownInterface(p);
	    }
			break;

  	case 32767:
	    if (buttonId == 24832) {
			int randomlyX = Misc.random(1);
			int randomlyY = Misc.random(1);
			p.frames.removeShownInterface(p);
			p.frames.removeOverlay(p);
			p.teleportTo(2519 + Misc.random(-1 + 2), 3571 + Misc.random(-1 + 2), 0, 4, 0, 1816, -1, 342, 0, -1, 0);
	    }
	    if (buttonId == 25344) {
			p.frames.removeOverlay(p);
			p.frames.removeShownInterface(p);
	    }
	break;

	case 430:
	    /*
	     * Lunar
	     */


	    if (buttonId == 20) { // 1
 		if (p.skillLvl[6] >= 70) { 
 		    if (hasReq(p, 557, 4) && hasReq(p, 563, 1) && hasReq(p, 9075, 2)) { 
				p.removeRunes("groupmoonclan");
  				int randomlyX = Misc.random(1);
  				int randomlyY = Misc.random(1);
   				p.teleportTo(2519 + Misc.random(-1 + 2), 3571 + Misc.random(-1 + 2), 0, 4, 0, 1816, -1, 342, 0, -1, 0);

  			for (Player TeleGroup : Server.engine.players) { 
  			    if (TeleGroup == null || (Misc.getDistance(TeleGroup.absX, TeleGroup.absY, p.absX, p.absY) > 1) || TeleGroup == p) { // 2
   					continue;
  			    }
   				TeleGroup.frames.showInterface(TeleGroup, 326);
   				TeleGroup.frames.setString(TeleGroup, TeleGroup.username , 326, 89);
   				TeleGroup.frames.setString(TeleGroup, "Ardougne", 326, 91);
  			}
  		    }
		}
	    }

	    if (buttonId == 0) {
                    if (p.skillLvl[6] >= 75) {
                        if (hasReq(p, 9075, 2) && hasReq(p, 555, 3) && hasReq(p, 563, 2)) {
				p.removeRunes("barb");
				p.resetAnimTimer = 8;
				p.frames.playSound(p, 200, 1, 0);
				p.teleportTo(2519 + Misc.random(-1 + 2), 3571 + Misc.random(-1 + 2), 0, 4, 0, 1816, 6304, 747, 0, 6000, 0);
                        } else {
                            	p.frames.sendMessage(p, "You dont have the required runes for this spell.");
                        }
                    } else {
                        p.frames.sendMessage(p, "You need level 75 magic to use this spell.");
                    }
	    }

	    if (buttonId == 3) {
                    if (p.skillLvl[6] >= 74) {
                        if (hasReq(p, 9075, 2) && hasReq(p, 564, 2) && hasReq(p, 563, 2)) {
					p.requestAnim(4411, 0);
					p.isPoisoned = false;
					p.poisonDelay = 0;
                            		p.requestGFX(738, 100);
					p.removeRunes("curegroup");
                                	p.frames.sendMessage(p, "You haved cured everyone around you from poison.");
					p.frames.playSound(p, 2884, 1, 0);

			    for (Player player : Server.engine.players) {
			      if (player != null) {
			        if (Misc.getDistance(p.absX, p.absY, player.absX, player.absY) <= 3) {
                            		player.requestGFX(744, 100);
                                	player.frames.sendMessage(player, "You haved been cured from poison.");
					player.frames.playSound(player, 2887, 1, 0);
					player.isPoisoned = false;
					player.poisonDelay = 0;
				}
			      }
			    }
                        } else {
                            	p.frames.sendMessage(p, "You dont have the required runes for this spell.");
                        }
                    } else {
                        p.frames.sendMessage(p, "You need level 74 magic to use this spell.");
                    }
	    }

	    if (buttonId == 4) {
                    if (p.skillLvl[6] >= 67) {
                        if (hasReq(p, 9075, 1) && hasReq(p, 564, 1) && hasReq(p, 556, 2)) {
	    			p.requestAnim(4413, 0);
				p.npcContactTimer = 8;
                            	p.requestGFX(728, 100);
			    } else {
                            	p.frames.sendMessage(p, "You dont have the required runes for this spell.");
			    }
                    } else {
                            p.frames.sendMessage(p, "You need magic level 67 to use this spell.");
                    }
	    }

	    if (buttonId == 7) {
                    if (p.skillLvl[6] >= 68) {
                        if (hasReq(p, 9075, 1) && hasReq(p, 555, 3) && hasReq(p, 554, 1)) {
	    			p.requestAnim(6294, 0);
				p.removeRunes("humidify");
                            	p.requestGFX(1061, 0);
				p.frames.playSound(p, 3614, 1, 0);
			    } else {
                            	p.frames.sendMessage(p, "You dont have the required runes for this spell.");
			    }
                    } else {
                            p.frames.sendMessage(p, "You need magic level 68 to use this spell.");
                    }
	    }

	    if (buttonId == 8) {
                    if (p.skillLvl[6] >= 71) {
                        if (hasReq(p, 9075, 2) && hasReq(p, 557, 2)) {
	    			p.requestAnim(6303, 0);
				p.removeRunes("hunter");
                            	p.requestGFX(1074, 100);
			    } else {
                            	p.frames.sendMessage(p, "You dont have the required runes for this spell.");
			    }
                    } else {
                            p.frames.sendMessage(p, "You need magic level 71 to use this spell.");
                    }
	    }

	    if (buttonId == 12) {
                    if (p.skillLvl[6] >= 96) {
                        if (hasReq(p, 9075, 3) && hasReq(p, 564, 2) && hasReq(p, 563, 1)) {

				p.frames.setString(p, "Modern", 230, 2);
				p.frames.setString(p, "Ancients", 230, 3);
				p.frames.setString(p, "None", 230, 4);
				p.frames.showChatboxInterface(p, 230);
				p.optionArray[0] = true;

			    } else {
                            	p.frames.sendMessage(p, "You dont have the required runes for this spell.");
			    }
                    } else {
                            p.frames.sendMessage(p, "You need magic level 96 to use this spell.");
                    }
	    }

	    if (buttonId == 15) {
                    if (p.skillLvl[6] >= 65) {
                        if (hasReq(p, 9075, 1) && hasReq(p, 554, 5) && hasReq(p, 555, 4)) {
	    			p.requestAnim(4413, 0);
				p.removeRunes("bakepie");
                            	p.requestGFX(746, 100);
			    } else {
                            	p.frames.sendMessage(p, "You dont have the required runes for this spell.");
			    }
                    } else {
                            p.frames.sendMessage(p, "You need magic level 65 to use this spell.");
                    }
	    }

	    if (buttonId == 10) {
                    if (p.skillLvl[6] >= 71) {
                        if (hasReq(p, 9075, 2) && hasReq(p, 564, 1) && hasReq(p, 559, 5)) {
	    			p.requestAnim(6295, 0);
	    			p.dreamTimer = 15;
				p.removeRunes("dream");
			    } else {
                            	p.frames.sendMessage(p, "You dont have the required runes for this spell.");
			    }
                    } else {
                            p.frames.sendMessage(p, "You need magic level 79 to use this spell.");
                    }
	    }

	    if (buttonId == 17) {
                    if (p.skillLvl[6] >= 85) {
                        if (hasReq(p, 9075, 3) && hasReq(p, 555, 10) && hasReq(p, 563, 3)) {
				p.removeRunes("catherby");
				p.resetAnimTimer = 8;
				p.frames.playSound(p, 200, 1, 0);
				p.teleportTo(2611, 3393, 0, 4, 0, 1816, 6304, 747, 0, 6000, 0);
                        } else {
                            	p.frames.sendMessage(p, "You dont have the required runes for this spell.");
                        }
                    } else {
                        p.frames.sendMessage(p, "You need level 85 magic to use this spell.");
                    }
	    }

	    if (buttonId == 18) {
                    if (p.skillLvl[6] >= 78) {
                        if (hasReq(p, 9075, 2) && hasReq(p, 555, 4) && hasReq(p, 563, 2)) {
				p.removeRunes("khazard");
				p.resetAnimTimer = 8;
				p.frames.playSound(p, 200, 1, 0);
				p.teleportTo(2660 + Misc.random(-1 + 2), 3158 + Misc.random(-1 + 2), 0, 4, 0, 1816, 6304, 747, 0, 6000, 0);
                        } else {
                            	p.frames.sendMessage(p, "You dont have the required runes for this spell.");
                        }
                    } else {
                        p.frames.sendMessage(p, "You need level 87 magic to use this spell.");
                    }
	    }

	    if (buttonId == 21) {
                    if (p.skillLvl[6] >= 87) {
                        if (hasReq(p, 9075, 3) && hasReq(p, 555, 10) && hasReq(p, 563, 3)) {
				p.removeRunes("catherby");
				p.resetAnimTimer = 8;
				p.frames.playSound(p, 200, 1, 0);
				p.teleportTo(2804 + Misc.random(-1 + 2), 3434 + Misc.random(-1 + 2), 0, 4, 0, 1816, 6304, 747, 0, 6000, 0);
                        } else {
                            	p.frames.sendMessage(p, "You dont have the required runes for this spell.");
                        }
                    } else {
                        p.frames.sendMessage(p, "You need level 87 magic to use this spell.");
                    }
	    }

	    if (buttonId == 23) {
                    if (p.skillLvl[6] >= 71) {
                        if (hasReq(p, 9075, 2) && hasReq(p, 564, 2) && hasReq(p, 563, 1)) {
			    if (p.isPoisoned) {
				p.requestAnim(4411, 0);
				p.isPoisoned = false;
				p.poisonDelay = 0;
                            	p.requestGFX(738, 100);
				p.removeRunes("cureme");
                                p.frames.sendMessage(p, "You haved cured yourself from poison.");
				p.frames.playSound(p, 2884, 1, 0);
			    } else {
				p.frames.sendMessage(p, "You are not poisoned!");
			    }
                        } else {
                            	p.frames.sendMessage(p, "You dont have the required runes for this spell.");
                        }
                    } else {
                        p.frames.sendMessage(p, "You need level 71 magic to use this spell.");
                    }
	    }

	    if (buttonId == 24) {
                    if (p.skillLvl[6] >= 72) {
                        if (hasReq(p, 9075, 2) && hasReq(p, 555, 1) && hasReq(p, 563, 1)) {
				p.removeRunes("waterbirth");
				p.resetAnimTimer = 8;
				p.frames.playSound(p, 200, 1, 0);
				p.teleportTo(2547 + Misc.random(-1 + 2), 3758 + Misc.random(-1 + 2), 0, 4, 0, 1816, 6304, 747, 0, 6000, 0);
                        } else {
                            	p.frames.sendMessage(p, "You dont have the required runes for this spell.");
                        }
                    } else {
                        p.frames.sendMessage(p, "You need level 72 magic to use this spell.");
                    }
	    }

	    /*if (buttonId == 30) {
                    if (p.skillLvl[6] >= 95) {
                        if (hasReq(p, 9075, 4) && hasReq(p, 565, 3) && hasReq(p, 563, 6)) {
			    for (Player player : Server.engine.players) {
					p.requestAnim(4411, 0);
					p.appendHit((p.getLevelForXP(3) / 3), 0);
					p.frames.setSkillLvl(p, 3);
					p.removeRunes("healgroup");
                                	p.frames.sendMessage(p, "You haved healed everyone around you.");

			      if (player != null) {
			        if (Misc.getDistance(p.absX, p.absY, player.absX, player.absY) <= 3) {
                            		player.requestGFX(745, 100);
                                	player.frames.sendMessage(player, "You haved been healed.");
					player.frames.playSound(player, 2895, 1, 0);
					//player.skillLvl[3] = player.getLevelForXP(3);
					player.frames.setSkillLvl(player, 3);
				}
			      }
			    }
                        } else {
                            	p.frames.sendMessage(p, "You dont have the required runes for this spell.");
                        }
                    } else {
                        p.frames.sendMessage(p, "You need level 95 magic to use this spell.");
                    }
	    }*/

	    if (buttonId == 14) {
		if (!p.usingVeng) {
			if (p.vengDelay > 0) {
				p.frames.sendMessage(p, "You can only use vengeance every 30 seconds!");
				return;
			}
			if (!p.vengRunes()) {
				p.frames.sendMessage(p, "You do not have enough runes to cast this spell.");
				return;
			}
			//p.frames.playSound(p, 2907, 1, 0);
			p.frames.playSoundInArea(p.absX, p.absY, 4,  2907, 1, 0);
			p.requestGFX(726, 100);
			p.requestAnim(4410, 0);
			p.usingVeng = true;
			p.removeRunes("veng");
			p.vengDelay = 50;
			p.vengUseDelay = 60; //30 seconds.
		} else {
			p.frames.sendMessage(p, "You already have Vengeance casted!");
		}
	    }
	break;

        case 464:
            /*
             * Emote tab.
             */
            if (buttonId == 2) // Yes
                p.requestAnim(855, 0);
            else if (buttonId == 3) // No
                p.requestAnim(856, 0);
            else if (buttonId == 4) // Bow
                p.requestAnim(858, 0);
            else if (buttonId == 5) // Angry
                p.requestAnim(859, 0);
            else if (buttonId == 6)  // Think
                p.requestAnim(857, 0);
            else if (buttonId == 7) // Wave
                p.requestAnim(863, 0);
            else if (buttonId == 8) // Shrug
                p.requestAnim(2113, 0);
            else if (buttonId == 9) // Cheer
                p.requestAnim(862, 0);
            else if (buttonId == 10) // Beckon
                p.requestAnim(864, 0);
            else if (buttonId == 11) // Laugh
                p.requestAnim(861, 0);
            else if (buttonId == 12) // Joy jump
                p.requestAnim(2109, 0);
            else if (buttonId == 13) // Yawn
                p.requestAnim(2111, 0);
            else if (buttonId == 14) // Dance
                p.requestAnim(866, 0);
            else if (buttonId == 15) // Jig
                p.requestAnim(2106, 0);
            else if (buttonId == 16) // Spin
                p.requestAnim(2107, 0);
            else if (buttonId == 17) // Headbang
                p.requestAnim(2108, 0);
            else if (buttonId == 18) // Cry
                p.requestAnim(860, 0);
            else if (buttonId == 19) { // Blow kiss
                p.requestGFX(1702, 0);
                p.requestAnim(0x558, 0);
            } else if (buttonId == 20) // Panic
                p.requestAnim(2105, 0);
            else if (buttonId == 21) // Raspberry
                p.requestAnim(2110, 0);
            else if (buttonId == 22) // Clap
                p.requestAnim(865, 0);
            else if (buttonId == 23) // Salute
                p.requestAnim(2112, 0);
            else if (buttonId == 24) // Goblin bow
                p.requestAnim(0x84F, 0);
            else if (buttonId == 25) // Goblin salute
                p.requestAnim(0x850, 0);
            else if (buttonId == 26) // Glass box
                p.requestAnim(1131, 0);
            else if (buttonId == 27) // Climb rope
                p.requestAnim(1130, 0);
            else if (buttonId == 28) // Lean
                p.requestAnim(1129, 0);
            else if (buttonId == 29) // Glass wall
                p.requestAnim(1128, 0);
            else if (buttonId == 30) // Head slap
                p.requestAnim(4275, 0);
            else if (buttonId == 31) // Stomp
                p.requestAnim(1745, 0);
            else if (buttonId == 32) // Flap
                p.requestAnim(4280, 0);
            else if (buttonId == 33) // Idea
                p.requestAnim(4276, 0);
            else if (buttonId == 34) // Zombie walk
                p.requestAnim(3544, 0);
            else if (buttonId == 35) // Dombie dance
                p.requestAnim(3543, 0);
            else if (buttonId == 36) { // Zombie hand grab
                p.requestGFX(1244, 0);
                p.requestAnim(7272, 0);
            } else if (buttonId == 37) // Scared
                p.requestAnim(2836, 0);
            else if (buttonId == 38) // Rabbit hop
                p.requestAnim(6111, 0);
            else if (buttonId == 39) { // Skillcape emotes
			if (!p.skillCapeEquiped()) {
				p.frames.sendMessage(p, "You need a skill cape equiped to perform this animation.");
				return;
			}
			if (p.animClickDelay > 0) {
				return;
			}
			if (p.equipment[1] == 9747 || p.equipment[1] == 10639 || p.equipment[1] == 9748) { //attack
                    		p.requestGFX(823,1);
	    	    		p.requestAnim(4959,1);
                	}
			if (p.equipment[1] == 9753 || p.equipment[1] == 10641 || p.equipment[1] == 9754) { //Defence
                    		p.requestGFX(824,1);
	    			p.requestAnim(4961,1);
                	}
			if (p.equipment[1] == 9750 || p.equipment[1] == 10640 || p.equipment[1] == 9751) { //Strength
                    		p.requestGFX(828,1);
	    			p.requestAnim(4981,1);
                	}
			if (p.equipment[1] == 9768 || p.equipment[1] == 10647 || p.equipment[1] == 9769) { //Hitpoints
                    		p.requestGFX(833,1);
	    			p.requestAnim(4971,1);
                	}
			if (p.equipment[1] == 9756 || p.equipment[1] == 10642 || p.equipment[1] == 9757) { //Range
                    		p.requestGFX(832,1);
	    			p.requestAnim(4973,1);
                	}
			if (p.equipment[1] == 9759 || p.equipment[1] == 10643 || p.equipment[1] == 9760) { //Prayer
                    		p.requestGFX(829,1);
	    			p.requestAnim(4979,1);
                	}
			if (p.equipment[1] == 9762 || p.equipment[1] == 10644 || p.equipment[1] == 9763) { //Magic
                    		p.requestGFX(813,1);
	    			p.requestAnim(4939,1);
                	}
			if (p.equipment[1] == 9801 || p.equipment[1] == 10658 || p.equipment[1] == 9802) { //Cooking
                    		p.requestGFX(821,1);
	    			p.requestAnim(4955,1);
                	}
			if (p.equipment[1] == 9807 || p.equipment[1] == 10660 || p.equipment[1] == 9808) { //Woodcutting
                    		p.requestGFX(822,1);
	    			p.requestAnim(4957,1);
                	}
			if (p.equipment[1] == 9783 || p.equipment[1] == 10652 || p.equipment[1] == 9784) { //Fletching
                    		p.requestGFX(812, 1);
	    			p.requestAnim(4937, 1);
                	}
			if (p.equipment[1] == 9798 || p.equipment[1] == 10657 || p.equipment[1] == 9799) { //Fishing
                   		p.requestGFX(819,1);
	    			p.requestAnim(4951,1);
                	}
			if (p.equipment[1] == 9804 || p.equipment[1] == 10659 || p.equipment[1] == 9805) { //Firemaking
                    		p.requestGFX(831,1);
	   			p.requestAnim(4975,1);
                	}
			if (p.equipment[1] == 9780 || p.equipment[1] == 10651 || p.equipment[1] == 9781) { //Crafting
                    		p.requestGFX(818,1);
	   			p.requestAnim(4949,1);
                	}
			if (p.equipment[1] == 9795 || p.equipment[1] == 10656 || p.equipment[1] == 9796) { //Smithing
                    		p.requestGFX(815,1);
	    			p.requestAnim(4943,1);
                	}
			if (p.equipment[1] == 9792 || p.equipment[1] == 10655 || p.equipment[1] == 9793) { //Mining
                    		p.requestGFX(814,1);
	    			p.requestAnim(4941,1);
                	}
			if (p.equipment[1] == 9774 || p.equipment[1] == 10649 || p.equipment[1] == 9775) { //Herblore
                    		p.requestGFX(835,1);
	    			p.requestAnim(4969,1);
                	}
			if (p.equipment[1] == 9771 || p.equipment[1] == 10648 || p.equipment[1] == 9772) { //Agility
                    		p.requestGFX(830,1);
	    			p.requestAnim(4977,1);
                	}
			if (p.equipment[1] == 9777 || p.equipment[1] == 10650 || p.equipment[1] == 9778) { //Theiving
                    		p.requestGFX(826,1);
	    			p.requestAnim(4965,1);
                	}
			if (p.equipment[1] == 9786 || p.equipment[1] == 10653 || p.equipment[1] == 9787) { //Slayer
                    		p.requestGFX(1656, 1);
	   			p.requestAnim(4967, 1);
                	}
			if (p.equipment[1] == 9810 || p.equipment[1] == 10661 || p.equipment[1] == 9811) { //Farming
                    		p.requestGFX(825,1);
	    			p.requestAnim(4963,1);
                	}
			if (p.equipment[1] == 9765 || p.equipment[1] == 10645 || p.equipment[1] == 9766) { //Runecrafting
                    		p.requestGFX(817,1);
	    			p.requestAnim(4947,1);
                	}
			if (p.equipment[1] == 9789 || p.equipment[1] == 10654 || p.equipment[1] == 9790) { //Construction
                   		 p.requestGFX(820,1);
	    			p.requestAnim(4953,1);
                	}
			if (p.equipment[1] == 12524 || p.equipment[1] == 12169 || p.equipment[1] == 12170) { //Summoning
                    		p.requestGFX(1515,1);
	    			p.requestAnim(8525,1);
                	}
			if (p.equipment[1] == 9948 || p.equipment[1] == 10646 || p.equipment[1] == 9949) { // hunter
            			p.requestGFX(907, 0);
            			p.requestAnim(5158, 0);
          		}
			if (p.equipment[1] == 9813 || p.equipment[1] == 10662) { //Quest
                    		p.requestGFX(816,1);
	    			p.requestAnim(4945,1);
                	}
			p.animClickDelay = 10;
	    }
            else if (buttonId == 40) // Snowman dance
                p.requestAnim(7531, 0); 
            else if (buttonId == 41) { // Air guitar
                p.requestAnim(2414, 0);
                p.requestGFX(1537, 0);
            } else if (buttonId == 42)  { // Safety first
                p.requestAnim(8770, 0); 
                p.requestGFX(1553, 0);
            }
        break;

	case 75:
	case 76:
	case 77:
	case 78:
	case 79:
	case 80:
	case 81:
	case 82:
	case 83:
	case 84:
	case 85:
	case 86:
	case 87:
	case 88:
	case 89:
	case 91:
	case 92:
	case 93:
		if (buttonId == 2) {
			p.fightStyle = 1;
		}
		if (buttonId == 3) {
			p.fightStyle = 2;
		}
		if (buttonId == 4) {
			p.fightStyle = 3;
		}
		if (buttonId == 5 && p.equipment[3] == 4718) {
			p.fightStyle = 2;
		} else if (buttonId == 5 && p.equipment[3] != 4718) {
			p.fightStyle = 4;
		}
		if (buttonId == 26 || buttonId == 24) {
			if (!p.autoAttack) {
				p.autoAttack = true;
				p.frames.setConfig(p, 172, 1);
			} else {
				p.autoAttack = false;
				p.frames.setConfig(p, 172, 0);
			}
		}
		if (buttonId == 8 || buttonId == 10 || buttonId == 11) {
			if (!p.usingSpecial) {
				if (p.specAmount > 0) {
					if (p.specAmount < p.neededSpecialAmount()) {
						p.frames.sendMessage(p, "You don't have enough special attack amount left.");
						p.combatDelay += 3;
						return;
					}
					if (p.equipment[3] != 1377) {
						p.frames.setConfig(p, 301, 1);
						p.usingSpecial = true;
					} else {
						if (p.specAmount >= 1000) {
							p.setBattleAxeStats();
							p.requestGFX(246, 0);
							p.requestAnim(1056, 0);
							p.requestForceChat("RAAARRRGHHHHH!!!");
							p.frames.setConfig2(p, 300, 0);
							p.specAmount = 0;
							p.usingSpecial = false;
						} else {
							p.frames.sendMessage(p, "You don't have enough special attack amount left.");
							p.frames.setConfig(p, 301, 0);
							p.usingSpecial = false;
						}
					}
				} else {
					p.frames.sendMessage(p, "You don't have enough special attack amount left.");
					p.frames.setConfig(p, 301, 0);
					p.usingSpecial = false;
				}
			} else {
				p.frames.setConfig(p, 301, 0);
				p.usingSpecial = false;
			}
		}
            	Misc.println("[" + p.username + "] Unhandled button: " + interfaceId + ", " + buttonId + ":" + buttonId2);
	break;

	case 90:
		for (int i = 0; i < p.regularStaffs.length; i++) {
			if (p.equipment[3] == p.regularStaffs[i]) {
				if (buttonId == 4 || buttonId == 5) {
					p.frames.setTab(p, 73, 319);
				}
			}
		}
		for (int a = 0; a < p.otherStaffs.length; a++) {
			if (p.equipment[3] == p.otherStaffs[a]) {
				if (buttonId == 4 || buttonId == 5) {
					p.frames.setTab(p, 73, 388);
				}
			}
		}
	break;

	case 319:
		if (buttonId == 15) {
		    if (p.getLevelForXP(6) >= 75) {
			p.autoCast[0] = 16;
			p.autoCast[1] = 0;
			p.castAuto = true;
		    } else {
			p.frames.sendMessage(p, "You need a magic level of 75 to cast this spell.");
		    }
		}
		if (buttonId == 14) {
		    if (p.getLevelForXP(6) >= 70) {
			p.autoCast[0] = 15;
			p.autoCast[1] = 0;
			p.castAuto = true;
		    } else {
			p.frames.sendMessage(p, "You need a magic level of 70 to cast this spell.");
		    }
		}
		if (buttonId == 13) {
		    if (p.getLevelForXP(6) >= 65) {
			p.autoCast[0] = 14;
			p.autoCast[1] = 0;
			p.castAuto = true;
		    } else {
			p.frames.sendMessage(p, "You need a magic level of 65 to cast this spell.");
		    }
		}
		if (buttonId == 12) {
		    if (p.getLevelForXP(6) >= 62) {
			p.autoCast[0] = 13;
			p.autoCast[1] = 0;
			p.castAuto = true;
		    } else {
			p.frames.sendMessage(p, "You need a magic level of 62 to cast this spell.");
		    }
		}
		if (buttonId == 11) {
		    if (p.getLevelForXP(6) >= 59) {
			p.autoCast[0] = 12;
			p.autoCast[1] = 0;
		    } else {
			p.frames.sendMessage(p, "You need a magic level of 59 to cast this spell.");
		    }
		}
		if (buttonId == 10) {
		    if (p.getLevelForXP(6) >= 53) {
			p.autoCast[0] = 11;
			p.autoCast[1] = 0;
			p.castAuto = true;
		    } else {
			p.frames.sendMessage(p, "You need a magic level of 53 to cast this spell.");
		    }
		}
		if (buttonId == 9) {
		    if (p.getLevelForXP(6) >= 47) {
			p.autoCast[0] = 10;
			p.autoCast[1] = 0;
			p.castAuto = true;
		    } else {
			p.frames.sendMessage(p, "You need a magic level of 47 to cast this spell.");
		    }
		}
		if (buttonId == 8) {
		    if (p.getLevelForXP(6) >= 41) {
			p.autoCast[0] = 9;
			p.autoCast[1] = 0;
			p.castAuto = true;
		    } else {
			p.frames.sendMessage(p, "You need a magic level of 41 to cast this spell.");
		    }
		}
		if (buttonId == 7) {
		    if (p.getLevelForXP(6) >= 35) {
			p.autoCast[0] = 8;
			p.autoCast[1] = 0;
			p.castAuto = true;
		    } else {
			p.frames.sendMessage(p, "You need a magic level of 35 to cast this spell.");
		    }
		}
		if (buttonId == 6) {
		    if (p.getLevelForXP(6) >= 29) {
			p.autoCast[0] = 7;
			p.autoCast[1] = 0;
			p.castAuto = true;
		    } else {
			p.frames.sendMessage(p, "You need a magic level of 29 to cast this spell.");
		    }
		}
		if (buttonId == 5) {
		    if (p.getLevelForXP(6) >= 23) {
			p.autoCast[0] = 6;
			p.autoCast[1] = 0;
			p.castAuto = true;
		    } else {
			p.frames.sendMessage(p, "You need a magic level of 23 to cast this spell.");
		    }
		}
		if (buttonId == 4) {
		    if (p.getLevelForXP(6) >= 17) {
			p.autoCast[0] = 5;
			p.autoCast[1] = 0;
			p.castAuto = true;
		    } else {
			p.frames.sendMessage(p, "You need a magic level of 17 to cast this spell.");
		    }
		}
		if (buttonId == 3) {
		    if (p.getLevelForXP(6) >= 13) {
			p.autoCast[0] = 4;
			p.autoCast[1] = 0;
			p.castAuto = true;
		    } else {
			p.frames.sendMessage(p, "You need a magic level of 13 to cast this spell.");
		    }
		}
		if (buttonId == 2) {
		    if (p.getLevelForXP(6) >= 9) {
			p.autoCast[0] = 3;
			p.autoCast[1] = 0;
			p.castAuto = true;
		    } else {
			p.frames.sendMessage(p, "You need a magic level of 9 to cast this spell.");
		    }
		}
		if (buttonId == 1) {
		    if (p.getLevelForXP(6) >= 5) {
			p.autoCast[0] = 2;
			p.autoCast[1] = 0;
			p.castAuto = true;
		    } else {
			p.frames.sendMessage(p, "You need a magic level of 5 to cast this spell.");
		    }
		}
		if (buttonId == 0) {
		    if(p.getLevelForXP(6) >= 1) {
			p.autoCast[0] = 1;
			p.autoCast[1] = 0;
			p.castAuto = true;
		    } else {
			p.frames.sendMessage(p, "You need a magic level of 1 to cast this spell.");
		    }
		}
		p.frames.setTab(p, 73, 90);
		p.playerWeapon.setWeapon();
	break;

	case 388:
		if (buttonId == 15) {
		    if(p.getLevelForXP(6) >= 94) {
			p.autoCast[1] = 16;
			p.autoCast[0] = 0;
			p.castAuto = true;
		    } else {
			p.frames.sendMessage(p, "You need a magic level of 1 to cast this spell.");
		    }
		}
		if (buttonId == 11) {
		    if(p.getLevelForXP(6) >= 82) {
			p.autoCast[1] = 12;
			p.autoCast[0] = 0;
			p.castAuto = true;
		    } else {
			p.frames.sendMessage(p, "You need a magic level of 82 to cast this spell.");
		    }
		}
		if (buttonId == 7) {
		    if(p.getLevelForXP(6) >= 70) {
			p.autoCast[1] = 8;
			p.autoCast[0] = 0;
			p.castAuto = true;
		    } else {
			p.frames.sendMessage(p, "You need a magic level of 70 to cast this spell.");
		    }
		}

		p.frames.setTab(p, 73, 90);
		p.playerWeapon.setWeapon();
	break;

        case 182:
            /*
             * Logout interface.
             */
	    if (p.deathDelay > 0 || p.isDead || p.randomDelay > 0) {
		p.frames.sendMessage(p, "You cannot logout during combat.");
		return;
	    }
	    if (p.combatDelay > 0 || p.cmbResetTimer > 0) {
		p.frames.sendMessage(p, "You cannot logout during combat.");
		return;
	    }
	    if (p.inJadCave()) {
		p.getFightClass().deleteFightNPCs();
	    }
            p.frames.logout(p);
            break;
        case 548:
		if (buttonId == 60) {
			p.frames.setOverlay(p, 755);
		}
            break;

	case 755:
//Close the world map
if (buttonId == 9) {
	p.frames.setMapRegion(p);
	p.frames.removeOverlay(p);
	p.frames.removeShownInterface(p);
	p.abslastX = 0;
	p.abslastY = 0;
    	p.fixtimer = -1;
	p.appearanceUpdateReq = true;
	p.updateReq = true;
 	}
                  break;


        case 523:
		if (buttonId == 100) {
			p.frames.removeOverlay(p);
			p.frames.removeShownInterface(p);
			p.frames.setTab(p, 79, 430);
		}
            break;

case 746:
		if(buttonId == 104) { //World map
		p.frames.setWindowPane(p, 755);
		}
if(buttonId == 49) //music tab
p.frames.setInterface(p, 1, 746, 71, 208);
if(buttonId == 43) //summon tab
p.frames.setInterface(p, 1, 746, 71, 208);
else if (buttonId == 48) //emote tab
p.frames.setInterface(p, 1, 746, 71, 208);
else if (buttonId == 47) //setting tab
p.frames.setInterface(p, 1, 746, 71, 208);
else if (buttonId == 46) //clan chat
p.frames.setInterface(p, 1, 746, 71, 208);
else if (buttonId == 45) //ignore tab
p.frames.setInterface(p, 1, 746, 71, 208);
else if (buttonId == 44) //friends list tab
p.frames.setInterface(p, 1, 746, 71, 208);
else if (buttonId == 42) //magic tab
p.frames.setInterface(p, 1, 746, 71, 208);
else if (buttonId == 41) //prayer tab
p.frames.setInterface(p, 1, 746, 71, 208);
else if (buttonId == 40) //Equipment tab
p.frames.setInterface(p, 1, 746, 71, 208);
else if (buttonId == 39) //Inventory tab
p.frames.setInterface(p, 1, 746, 71, 208); 
else if (buttonId == 38) //quest tab
p.frames.setInterface(p, 1, 746, 71, 208); 
else if (buttonId == 37) //Skill tab
p.frames.setInterface(p, 1, 746, 71, 208);
if (buttonId == 36) { //Attack tab
p.playerWeapon.setWeapon();
p.frames.setInterface(p, 1, 746, 71, 208);
}
if (buttonId == 35) //sum tab 
p.frames.setInterface(p, 1, 746, 71, 208); 
else if (buttonId == 12) //Logout.
p.frames.setInterface(p, 1, 746, 71, 208);
		break;
        case 763:
            /*
             * Inventory interface with banking.
             */
            if (p.interfaceId != 762) {
                return;
            }
            if (buttonId == 0) {
                if (packetId == 233)		//1
                    Engine.playerBank.bankItem(p, buttonId2, 1);
                else if (packetId == 21)	//5
                    Engine.playerBank.bankItem(p, buttonId2, 5);
                else if (packetId == 169)	//10
                    Engine.playerBank.bankItem(p, buttonId2, 10);
				//else if (packetId == 214)	//lastX
					//Engine.playerBank.bankItem(p, buttonId2, p.bankX);
                else if (packetId == 232)	//all
                    Engine.playerBank.bankItem(p, buttonId2, Engine.playerItems.invItemCount(p, p.items[buttonId2]));
				//else if (packetId == 173)	//X
					//p.input.request(3, buttonId2);
				else if (packetId == 90)	//examine
				    p.frames.sendMessage(p, Engine.items.getItemDescription(p.items[buttonId2]));
            }
            break;
	case 631:
            Misc.println("[" + p.username + "] Unhandled button: " + interfaceId + ", " + buttonId + ":" + buttonId2);
	    if (buttonId == 23) {
		Player pl = Server.engine.players[p.duelFriend];
		if (p != null && pl != null) {
			p.frames.removeShownInterface(p);
			pl.frames.removeShownInterface(pl);
			p.getDuelClass().resetDuelSettings1();
	        	pl.getDuelClass().resetDuelSettings1();
		}
	    }
	    if (buttonId == 102) {/* Accept */
		Player pl = Server.engine.players[p.duelFriend];
		if (p != null && pl != null) {
			p.acceptScreen1 = true;
			p.frames.sendMessage(p, "Accepted duel.");
			p.frames.setString(p, "Waiting for other player...", 631, 28);
		}
	    }
	    if (buttonId == 107) {/* Decline */
		Player pl = Server.engine.players[p.duelFriend];
		if (p != null && pl != null) {
			p.frames.removeShownInterface(p);
			pl.frames.removeShownInterface(pl);
			p.getDuelClass().resetDuelSettings1();
	        	pl.getDuelClass().resetDuelSettings1();
		}
	    }
	    if (buttonId == 30) {/* No Range */
		Player pl = Server.engine.players[p.duelFriend];
		if (p != null && pl != null) {
		p.frames.setConfig(p, 286, 16);
		pl.frames.setConfig(pl, 286, 16);
		}
	}
	    if (buttonId == 32) {/* No Melee */
		p.frames.setConfig(p, 286, 32);
		}
	    if (buttonId == 34) {/* No Magic */
		p.frames.setConfig(p, 286, 64);
		}
	    if (buttonId == 36) {/* Fun Weapons */
		p.frames.setConfig(p, 286, 4096);
		}
	    if (buttonId == 38) {/* No Forfeit */
		p.frames.setConfig(p, 286, 1);
		}
	    if (buttonId == 40) {/* No Drink */
		p.frames.setConfig(p, 286, 128);
		}
	    if (buttonId == 42) {/* No Food */
		p.frames.setConfig(p, 286, 256);
		}
	    if (buttonId == 44) {/* No Prayer */
		p.frames.setConfig(p, 286, 512);
		}
	    if (buttonId == 46) {/* No Movement */
		p.frames.setConfig(p, 286, 2);
		}
	    if (buttonId == 48) {/* Obstacles */
		p.frames.setConfig(p, 286, 1024);
		}
	    if (buttonId == 53) {/* Enable Summoning */
		p.frames.setConfig(p, 286, 2684354);
		}
	    if (buttonId == 51) {/* Specs */
		Player pl = Server.engine.players[p.duelFriend];
		p.frames.setConfig(p, 286, 8192);
		pl.frames.setConfig(pl, 286, 8192);
		}
	    if (buttonId == 61) {/* No Weapons */
		p.frames.setConfig(p, 286, 131072);
		}
	    if (buttonId == 62) {/* No Body */
		p.frames.setConfig(p, 286, 262144);
		}
	    if (buttonId == 63) {/* No Shield */
		p.frames.setConfig(p, 286, 524288);
		}
	    if (buttonId == 64) {/* No Legs */
		p.frames.setConfig(p, 286, 2097152);
		}
	    if (buttonId == 67) {/* No Gloves */
		p.frames.setConfig(p, 286, 8388608);
		}
	    if (buttonId == 66) {/* No Boots */
		p.frames.setConfig(p, 286, 16777216);
		}
	    if (buttonId == 67) {/* No Gloves */
		p.frames.setConfig(p, 286, 8388608);
		}
	    if (buttonId == 65) {/* No Rings */
		p.frames.setConfig(p, 286, 67108864);
		}
	    if (buttonId == 60) {/* No Arrows */
		p.frames.setConfig(p, 286, 134217728);
		}
	    if (buttonId == 57) {/* No Helms */
		p.frames.setConfig(p, 286, 16384);
		}
	    if (buttonId == 58) {/* No Capes */
		p.frames.setConfig(p, 286, 32768);
		}
	    break;


	case 637:
            Misc.println("[" + p.username + "] Unhandled button: " + interfaceId + ", " + buttonId + ":" + buttonId2);
	    if (buttonId == 14) {
		Player pl = Server.engine.players[p.duelFriend];
		if (p != null && pl != null) {
			p.frames.removeShownInterface(p);
			pl.frames.removeShownInterface(pl);
			p.getDuelClass().resetDuelSettings1();
	        	pl.getDuelClass().resetDuelSettings1();
		}
	    }
	    if (buttonId == 83) {/* Accept */
		Player pl = Server.engine.players[p.duelFriend];
		if (p != null && pl != null) {
			p.acceptScreen1 = true;
			//p.frames.sendMessage(p, "Accepted duel.");
			p.frames.setString(p, "Waiting for other player...", 637, 45);
		}
	    }
	    if (buttonId == 86) {/* Decline */
		Player pl = Server.engine.players[p.duelFriend];
		if (p != null && pl != null) {
			p.frames.removeShownInterface(p);
			pl.frames.removeShownInterface(pl);
			p.getDuelClass().resetDuelSettings1();
	        	pl.getDuelClass().resetDuelSettings1();
		}
	    }
	    break;
	case 640:
	    if (buttonId == 18) {
		p.frames.removeShownInterface(p);
		p.teleportTo(3087 + Misc.random(2), 3518 + Misc.random(2), 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
	    }
	    if (buttonId == 19) {
		p.frames.removeShownInterface(p);
		p.teleportTo(3243 + Misc.random(8), 3533 + Misc.random(8), 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
	    }
	    if (buttonId == 20) {
		p.frames.removeShownInterface(p);
		p.teleportTo(3091 + Misc.random(2), 3963 + Misc.random(2), 0, 4, 0, 8939, 8941, 1576, 0, 1577, 0);
	    }
	break;



	case 591:
		p.appearanceUpdateReq = true;
		p.updateReq = true;
	    switch(buttonId) {
					/*case 590:
				if (buttonId == 22) {
					switch(packetId) {
						case 233:
							p.showInputInterface4(p, 0, "Enter clan prefix:");
						break;
						case 21:
						    p.frames.setString(p, "Chat disabled" , 590, 22);
						    //Server.ClanMain.clanName3(p, "");
						    break;
					}
				}
			break;*/

		case 180:
			p.frames.removeShownInterface(p);
			break;

	/* Start Torso's */

		default:
			Misc.println("Unhandled char screen button: "  + buttonId + ":" + buttonId2);
			break;
	    }
	break;


	case 592:
			p.appearanceUpdateReq = true;
			p.updateReq = true;
		if (buttonId == 168) { // Bald
			p.look[0] = 45;
		}
		if (buttonId == 169) { // Bun
			p.look[0] = 46;
		}
		if (buttonId == 170) { // Dreadlocks
			p.look[0] = 47;
		}
		if (buttonId == 171) { // Long
			p.look[0] = 48;
		}
		if (buttonId == 172) { // Short
			p.look[0] = 49;
		}
		if (buttonId == 173) { // Pigtails
			p.look[0] = 50;
		}
		if (buttonId == 174) { // Crew cut
			p.look[0] = 51;
		}
		if (buttonId == 175) { // Close cropped
			p.look[0] = 52;
		}
		if (buttonId == 176) { // Wild spikes
			p.look[0] = 53;
		}
		if (buttonId == 177) { // Spikes
			p.look[0] = 54;
		}
		if (buttonId == 178) {
			p.look[0] = 135;
		}
		if (buttonId == 179) {
			p.look[0] = 136;
		}
		if (buttonId == 180) {
			p.look[0] = 137;
		}
		if (buttonId == 181) {
			p.look[0] = 138;
		}
		if (buttonId == 182) {
			p.look[0] = 139;
		}
		if (buttonId == 183) {
			p.look[0] = 140;
		}
		if (buttonId == 184) {
			p.look[0] = 141;
		}
		if (buttonId == 185) {
			p.look[0] = 142;
		}
		if (buttonId == 186) {
			p.look[0] = 143;
		}
		if (buttonId == 187) {
			p.look[0] = 144;
		}
	break;



	case 596:
		if (buttonId == 245) {
			p.color[0] = 1;
		}
		if (buttonId == 228) {
			p.color[0] = 4;
		}
		if (buttonId == 229) {
			p.color[0] = 5;
		}
		if (buttonId == 233) {
			p.color[0] = 6;
		}
		if (buttonId == 231) {
			p.color[0] = 7;
		}
		if (buttonId == 235) {
			p.color[0] = 9;
		}
		if (buttonId == 226) {
			p.color[0] = 10;
		}
		if (buttonId == 240) {
			p.color[0] = 11;
		}
		if (buttonId == 243) {
			p.color[0] = 3;
		}
		if (buttonId == 247) {
			p.color[0] = 13;
		}
		if (buttonId == 230) {
			p.color[0] = 15;
		}
		if (buttonId == 239) {
			p.color[0] = 16;
		}
		if (buttonId == 227) {
			p.color[0] = 18;
		}
		if (buttonId == 225) {
			p.color[0] = 19;
		}
		if (buttonId == 224) {
			p.color[0] = 20;
		}
		if (buttonId == 234) {
			p.color[0] = 21;
		}
		if (buttonId == 236) {
			p.color[0] = 22;
		}
		if (buttonId == 242) {
			p.color[0] = 23;
		}
		if (buttonId == 241) {
			p.color[0] = 24;
		}
		if (buttonId == 232) {
			p.color[0] = 25;
		}
		if (buttonId == 237) {
			p.color[0] = 17;
		}
		if (buttonId == 246) {
			p.color[0] = 14;
		}
		if (buttonId == 244) {
			p.color[0] = 2;
		}
		if (buttonId == 248) {
			p.color[0] = 12;
		}
		if (buttonId == 238) {
			p.color[0] = 8;
		}
		if (buttonId == 160) {
			p.frames.removeShownInterface(p);
		}
		if (buttonId == 167) { // Bald
			p.look[0] = 0;
		}
		if (buttonId == 168) { // Dreadlocks
			p.look[0] = 1;
		}
		if (buttonId == 169) { // Long hair
			p.look[0] = 2;
		}
		if (buttonId == 170) { // Long hair
			p.look[0] = 3;
		}
		if (buttonId == 171) { // Crew cut
			p.look[0] = 4;
		}
		if (buttonId == 172) { // Crew cut
			p.look[0] = 5;
		}
		if (buttonId == 173) { // Crew cut
			p.look[0] = 6;
		}
		if (buttonId == 174) { // Wild spikes
			p.look[0] = 7;
		}
		if (buttonId == 175) { // Spikes
			p.look[0] = 8;
		}
		if (buttonId == 176) { // Mohawk
			p.look[0] = 91;
		}
		if (buttonId == 177) {
			p.look[0] = 92;
		}
		if (buttonId == 178) {
			p.look[0] = 93;
		}
		if (buttonId == 179) {
			p.look[0] = 94;
		}
		if (buttonId == 180) {
			p.look[0] = 95;
		}
		if (buttonId == 181) {
			p.look[0] = 96;
		}
		if (buttonId == 182) {
			p.look[0] = 97;
	    } else if(buttonId != 160 || buttonId !=167 || buttonId !=168 || buttonId !=169 || buttonId !=170 || buttonId !=171 || buttonId !=172 || buttonId !=173 || buttonId !=174 || buttonId !=175 || buttonId !=176 || buttonId !=177 || buttonId !=178 || buttonId !=179 || buttonId !=180 || buttonId !=181 || buttonId !=182) {
			Misc.println("Unhandled hair button: "  + buttonId);
	    }
			p.appearanceUpdateReq = true;
			p.updateReq = true;
	break;

        case 762:
            /*
             * Bank interface.
             */
		p.NpcWanneTalk = 0;
		p.NpcDialogue = 0;
		p.NpcDialogueSend = true;

            if (p.interfaceId != 762) {
                return;
            }	
            if (buttonId == 73) {
                if (packetId == 233)	//1
                    Engine.playerBank.bankWithdraw(p, buttonId2, 1);
                else if (packetId == 21)	//5
                    Engine.playerBank.bankWithdraw(p, buttonId2, 5);
                else if (packetId == 169)	//10
                    Engine.playerBank.bankWithdraw(p, buttonId2, 10);
				//else if (packetId == 214)	//lastX
					//Engine.playerBank.bankWithdraw(p, buttonId2, p.bankX);
				else if (packetId == 173) {	//X
					//p.input.request(2, buttonId2); This is mine, replace with yours
				} else if (packetId == 232)	//all
                    Engine.playerBank.bankWithdraw(p, buttonId2, p.bankItemsN[buttonId2]);
				else if (packetId == 133)	//all but one
					Engine.playerBank.bankWithdraw(p, buttonId2, p.bankItemsN[buttonId2] -1);
				else if (packetId == 90)	//examine
				    p.frames.sendMessage(p, Engine.items.getItemDescription(p.bankItems[buttonId2]));
                break;
            } else if (buttonId == 22) {
				//p.frames.restoreTabs(p); This is mine, close interface button, you might have other methods to show inventory again
			} else if (buttonId == 16) {
				p.withdrawNote = !p.withdrawNote;
			} else if (buttonId == 14) {
				p.insertMode = !p.insertMode;
			} else if (buttonId == 41 || buttonId == 39 || buttonId == 37 || buttonId == 35 || buttonId == 33 || buttonId == 31 || buttonId == 29 || buttonId == 27 || buttonId == 25) { //Tab buttons
				if(packetId == 21) { //Collapse
					Engine.playerBank.collapseTab(p, Engine.playerBank.getArrayIndex(buttonId)); //This method will be added later, dont worry
				} else if(packetId == 233) { //View tab
					p.viewingBankTab = Engine.playerBank.getArrayIndex(buttonId);
				}
			}
            break;
        default:
            Misc.println("[" + p.username + "] Unhandled button: " + interfaceId + ", " + buttonId + ":" + buttonId2);
            break;
        }
    }

    public static boolean hasReq(Player p, int ItemId, int amt) {
        return Engine.playerItems.haveItem(p, ItemId, amt);
    }
}

